transaction: Fix fetch_object result slicing

Needs to match the original C code:

    memmove(data, data + 1 + offs, outlen);
This commit is contained in:
Tony Arcieri
2019-11-25 08:58:19 -08:00
parent 79b1142f21
commit 63d7a21c9d
+4 -4
View File
@@ -489,7 +489,7 @@ impl<'tx> Transaction<'tx> {
return Err(Error::GenericError); return Err(Error::GenericError);
} }
let mut data = response.into_buffer(); let data = response.into_buffer();
let mut outlen = 0; let mut outlen = 0;
if data.len() < 2 || !has_valid_length(&data[1..], data.len() - 1) { if data.len() < 2 || !has_valid_length(&data[1..], data.len() - 1) {
@@ -512,9 +512,9 @@ impl<'tx> Transaction<'tx> {
return Err(Error::SizeError); return Err(Error::SizeError);
} }
// Remove the length tag Ok(Zeroizing::new(
data.remove(0); data[(1 + offs)..(1 + offs + outlen)].to_vec(),
Ok(data) ))
} }
/// Save an object /// Save an object