>From 88918bc77be35b33bb91834d96588818310078f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A1draig=20Brady?= Date: Thu, 23 Sep 2021 22:45:53 +0100 Subject: [PATCH] cksum: fix -a crc on 64 bit big endian systems * src/cksum.c (crc_sum_stream): On sparc64 for example, a crc of 0 was printed due to mismatch in size of variable copied between generator and output functions. uint_fast32_t is generally 64 bits on 64 bit systems, so we copy through an int to ensure we don't use the wrong end of a 64 bit variable. Reported by Nelson H. F. Beebe --- src/cksum.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/cksum.c b/src/cksum.c index 116d23f80..51afe89f6 100644 --- a/src/cksum.c +++ b/src/cksum.c @@ -275,7 +275,8 @@ crc_sum_stream (FILE *stream, void *resstream, uintmax_t *length) crc = (crc << 8) ^ crctab[0][((crc >> 24) ^ total_bytes) & 0xFF]; crc = ~crc & 0xFFFFFFFF; - memcpy (resstream, &crc, sizeof crc); + unsigned int crc_out = crc; + memcpy (resstream, &crc_out, sizeof crc_out); return 0; } -- 2.26.2