From: Simon Glass Date: Thu, 18 Apr 2013 10:25:51 +0000 (+0000) Subject: crc32: Correct endianness of crc32 result X-Git-Tag: v2013.04~1 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=74a18ee8a563d9c21b5856269f911b69bc4aaccb;p=oweals%2Fu-boot.git crc32: Correct endianness of crc32 result When crc32 is handled by the hash library, it requires the data to be in big-endian format, since it reads it byte-wise. Thus at present the 'crc32' command reports incorrect data. For example, previously we might see: Peach # crc32 40000000 100 CRC32 for 40000000 ... 400000ff ==> 0d968558 but instead with the hash library we see: Peach # crc32 40000000 100 CRC32 for 40000000 ... 400000ff ==> 5885960d Correct this. Signed-off-by: Simon Glass Reviewed-by: Vadim Bendebury --- diff --git a/lib/crc32.c b/lib/crc32.c index 76205da4f3..9759212486 100644 --- a/lib/crc32.c +++ b/lib/crc32.c @@ -8,7 +8,9 @@ * For conditions of distribution and use, see copyright notice in zlib.h */ -#ifndef USE_HOSTCC +#ifdef USE_HOSTCC +#include +#else #include #endif #include @@ -256,5 +258,6 @@ void crc32_wd_buf(const unsigned char *input, unsigned int ilen, uint32_t crc; crc = crc32_wd(0, input, ilen, chunk_sz); + crc = htonl(crc); memcpy(output, &crc, sizeof(crc)); }