NetBSD/usr.bin/gzip
kamil 2760f15b81 Correct Undefined Behavior in gzip(1)
Unportable left shift reported with MKSANITIZER=yes USE_SANITIZER=undefined:

# progress -zf ./games.tgz  tar -xp -C "./" -f -
/public/src.git/usr.bin/gzip/gzip.c:2126:33: runtime error: left shift of 251 by 24 places cannot be represented in type 'int'
100% |****************************************************************************************************************| 44500 KiB  119.69 MiB/s    00:00 ETA


Refactor the following code into something that is more clear
and fix signed integer shift, by casting all buf[] elements to
(unsigned int):

unsigned char buf[8];
uint32_t usize;
[...]
else {
    usize = buf[4] | buf[5] << 8 |
            buf[6] << 16 | buf[7] << 24;
[...]

New version:

    usize = buf[4];
    usize |= (unsigned int)buf[5] << 8;
    usize |= (unsigned int)buf[6] << 16;
    usize |= (unsigned int)buf[7] << 24;

Only the "<< 24" part needs explicit cast, but for consistency make the
integer promotion explicit and clear to a code reader.

Sponsored by <The NetBSD Foundation>
2018-06-12 00:42:17 +00:00
..
Makefile Add zfgrep that fell off from last update 2013-11-13 11:12:24 +00:00
gzexe
gzexe.1
gzip.1 Add gunzip and zcat to the NAME section as well 2017-10-22 17:36:49 +00:00
gzip.c Correct Undefined Behavior in gzip(1) 2018-06-12 00:42:17 +00:00
unbzip2.c add SIGINFO support. 2017-08-04 07:27:08 +00:00
unpack.c add SIGINFO support. 2017-08-04 07:27:08 +00:00
unxz.c add SIGINFO support. 2017-08-04 07:27:08 +00:00
zdiff
zdiff.1
zforce
zforce.1
zgrep zgrep(1): suppress the prefixing of filename on output when only 2015-07-06 12:05:40 +00:00
zgrep.1
zmore fix == compatibility problem 2013-12-06 13:33:15 +00:00
zmore.1 Added zless(1) - comes in the lastest version of zmore(1) from OpenBSD 2013-11-12 21:58:37 +00:00
znew
znew.1
zuncompress.c