You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
rust-plist/0001-Make-sure-offset_table...

44 lines
2.1 KiB

From 2b984085425549496b365255e807d1b45ac57e69 Mon Sep 17 00:00:00 2001
From: Josh Stone <cuviper@gmail.com>
Date: Thu, 16 Jan 2020 12:52:53 -0800
Subject: [PATCH 1/2] Make sure offset_table_offset is written as 8 bytes
It's a `usize` value, but the output format expects 8 bytes. That's fine
on 64-bit targets, but 32-bit targets were failing tests:
---- stream::binary_writer::tests::bplist_roundtrip stdout ----
thread 'stream::binary_writer::tests::bplist_roundtrip' panicked at 'assertion failed: `(left == right)`
left: `8`,
right: `4`: destination and source slices have different lengths', src/libcore/slice/mod.rs:2217:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
---- stream::binary_writer::tests::nskeyedarchiver_roundtrip stdout ----
thread 'stream::binary_writer::tests::nskeyedarchiver_roundtrip' panicked at 'assertion failed: `(left == right)`
left: `8`,
right: `4`: destination and source slices have different lengths', src/libcore/slice/mod.rs:2217:9
---- stream::binary_writer::tests::utf16_roundtrip stdout ----
thread 'stream::binary_writer::tests::utf16_roundtrip' panicked at 'assertion failed: `(left == right)`
left: `8`,
right: `4`: destination and source slices have different lengths', src/libcore/slice/mod.rs:2217:9
Casting to `u64` makes sure we have the correct size to write.
---
src/stream/binary_writer.rs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/stream/binary_writer.rs b/src/stream/binary_writer.rs
index 6541ea8d09d5..fe1e0902cda8 100644
--- a/src/stream/binary_writer.rs
+++ b/src/stream/binary_writer.rs
@@ -335,7 +335,7 @@ impl<W: Write> BinaryWriter<W> {
trailer[6] = offset_size;
trailer[7] = ref_size;
trailer[8..16].copy_from_slice(&(self.num_objects as u64).to_be_bytes());
- trailer[24..32].copy_from_slice(&offset_table_offset.to_be_bytes());
+ trailer[24..32].copy_from_slice(&(offset_table_offset as u64).to_be_bytes());
self.writer.write_exact(&trailer)?;
self.writer
--
2.24.1