From 63d7a21c9de83e68e685603a2fa87d1bcc2a96a2 Mon Sep 17 00:00:00 2001 From: Tony Arcieri Date: Mon, 25 Nov 2019 08:58:19 -0800 Subject: [PATCH] transaction: Fix `fetch_object` result slicing Needs to match the original C code: memmove(data, data + 1 + offs, outlen); --- src/transaction.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/transaction.rs b/src/transaction.rs index eda7104..62e2910 100644 --- a/src/transaction.rs +++ b/src/transaction.rs @@ -489,7 +489,7 @@ impl<'tx> Transaction<'tx> { return Err(Error::GenericError); } - let mut data = response.into_buffer(); + let data = response.into_buffer(); let mut outlen = 0; if data.len() < 2 || !has_valid_length(&data[1..], data.len() - 1) { @@ -512,9 +512,9 @@ impl<'tx> Transaction<'tx> { return Err(Error::SizeError); } - // Remove the length tag - data.remove(0); - Ok(data) + Ok(Zeroizing::new( + data[(1 + offs)..(1 + offs + outlen)].to_vec(), + )) } /// Save an object