From 0d8cc1670cdb6c4acdad1e2fcd92cb378873355b Mon Sep 17 00:00:00 2001 From: Eric Andersen Date: Wed, 27 Jun 2001 06:15:50 +0000 Subject: [PATCH] Fix a type promotion bug discivered and analyzed by Alan Modra , which caused false checksum errors --- archival/libunarchive/decompress_unzip.c | 2 +- archival/libunarchive/unzip.c | 2 +- libbb/unzip.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/archival/libunarchive/decompress_unzip.c b/archival/libunarchive/decompress_unzip.c index 7de28930a..40b8af427 100644 --- a/archival/libunarchive/decompress_unzip.c +++ b/archival/libunarchive/decompress_unzip.c @@ -997,7 +997,7 @@ extern int unzip(FILE *l_in_file, FILE *l_out_file) fread(buf, 1, 8, in_file); /* Validate decompression - crc */ - if (((buf[0] | (buf[1] << 8)) |((buf[2] | (buf[3] << 8)) << 16)) != (crc ^ 0xffffffffL)) { + if ((unsigned int)((buf[0] | (buf[1] << 8)) |((buf[2] | (buf[3] << 8)) << 16)) != (crc ^ 0xffffffffL)) { error_msg("invalid compressed data--crc error"); } /* Validate decompression - size */ diff --git a/archival/libunarchive/unzip.c b/archival/libunarchive/unzip.c index 7de28930a..40b8af427 100644 --- a/archival/libunarchive/unzip.c +++ b/archival/libunarchive/unzip.c @@ -997,7 +997,7 @@ extern int unzip(FILE *l_in_file, FILE *l_out_file) fread(buf, 1, 8, in_file); /* Validate decompression - crc */ - if (((buf[0] | (buf[1] << 8)) |((buf[2] | (buf[3] << 8)) << 16)) != (crc ^ 0xffffffffL)) { + if ((unsigned int)((buf[0] | (buf[1] << 8)) |((buf[2] | (buf[3] << 8)) << 16)) != (crc ^ 0xffffffffL)) { error_msg("invalid compressed data--crc error"); } /* Validate decompression - size */ diff --git a/libbb/unzip.c b/libbb/unzip.c index 7de28930a..40b8af427 100644 --- a/libbb/unzip.c +++ b/libbb/unzip.c @@ -997,7 +997,7 @@ extern int unzip(FILE *l_in_file, FILE *l_out_file) fread(buf, 1, 8, in_file); /* Validate decompression - crc */ - if (((buf[0] | (buf[1] << 8)) |((buf[2] | (buf[3] << 8)) << 16)) != (crc ^ 0xffffffffL)) { + if ((unsigned int)((buf[0] | (buf[1] << 8)) |((buf[2] | (buf[3] << 8)) << 16)) != (crc ^ 0xffffffffL)) { error_msg("invalid compressed data--crc error"); } /* Validate decompression - size */ -- 2.25.1