parent
b0b90b257c
commit
1a8fa74dd3
@ -1,35 +0,0 @@
|
|||||||
From e1a09f57546c9627ca576a39b84e2105d25b1e77 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Josh Stone <jistone@redhat.com>
|
|
||||||
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
|
|
||||||
|
|
@ -1 +1 @@
|
|||||||
SHA512 (tar-0.4.17.crate) = 3c6962d6c5dd3326ec668afbfa25d9750004f5f2979600322b6032d5d51b608baaae9eca6b2fb6ca6613961523da754eb4bbebd7275670978758d7b8c51b58fd
|
SHA512 (tar-0.4.19.crate) = 9fc8ecc0ee4776b312918d4a32ac312f5fad0b9df039046e1cf8c36671b6cb72a4fce5ad8e9a8dd35a2e960db33724f1b21047b94392a87f337e74beeddc403d
|
||||||
|
Loading…
Reference in new issue