diff --git a/0001-Always-write-big-endian-in-numeric_extended_into.patch b/0001-Always-write-big-endian-in-numeric_extended_into.patch new file mode 100644 index 0000000..9331801 --- /dev/null +++ b/0001-Always-write-big-endian-in-numeric_extended_into.patch @@ -0,0 +1,35 @@ +From e1a09f57546c9627ca576a39b84e2105d25b1e77 Mon Sep 17 00:00:00 2001 +From: Josh Stone +Date: Thu, 27 Sep 2018 23:03:52 -0700 +Subject: [PATCH] Always write big-endian in numeric_extended_into + +Before, this was transforming the number `to_be()`, then pulling out +least-significant bytes at shr 0, 8, 16, etc. This has the effect of +writing reversed bytes on a little-endian target. But since `to_be()` +does nothing on actual big-endian machines, they end up incorrectly +writing the true least-significant bytes first. + +Instead, we can just reverse the order of the shift indexes, and then +the platform endianness is irrelevant. + +Fixes #161. +--- + src/header.rs | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/header.rs b/src/header.rs +index 124c466d9874..0f2d7bd9c148 100644 +--- a/src/header.rs ++++ b/src/header.rs +@@ -1422,7 +1422,7 @@ fn numeric_extended_into(dst: &mut [u8], src: u64) { + let len: usize = dst.len(); + for (slot, val) in dst.iter_mut().zip( + repeat(0).take(len - 8) // to zero init extra bytes +- .chain((0..8).map(|x| ((src.to_be() >> (8 * x)) & 0xff) as u8)), ++ .chain((0..8).rev().map(|x| ((src >> (8 * x)) & 0xff) as u8)), + ) { + *slot = val; + } +-- +2.17.1 + diff --git a/rust-tar.spec b/rust-tar.spec index 988e73f..b09cdde 100644 --- a/rust-tar.spec +++ b/rust-tar.spec @@ -17,6 +17,9 @@ Source0: https://crates.io/api/v1/crates/%{crate}/%{version}/download#/%{ # * No redox Patch0: tar-0.4.15-fix-metadata.diff +# https://github.com/alexcrichton/tar-rs/pull/163 +Patch1: 0001-Always-write-big-endian-in-numeric_extended_into.patch + ExclusiveArch: %{rust_arches} BuildRequires: rust-packaging