Fix gzip byte counts with 32-bit integers
authorgkoehler <gkoehler@openbsd.org>
Sat, 18 Jun 2022 03:23:19 +0000 (03:23 +0000)
committergkoehler <gkoehler@openbsd.org>
Sat, 18 Jun 2022 03:23:19 +0000 (03:23 +0000)
commitaf40fb16f3e1e31774f101fcc651af1e7f81af65
tree657a0f22fd4edfbd19b9038b7b17b4a53e489b96
parent0c10332af909747af443c5d5791f0995fa850470
Fix gzip byte counts with 32-bit integers

If zlib is without our local change in lib/libz/zlib.h r1.7, then
s->z_stream.total_in and s->z_stream.total_out might overflow on
architectures where uLong has 32 bits.  After overflow, the total
would be 4G below the correct total.

Calculate our own 64-bit totals.  When decompressing, take
(uLong)s->z_stream.total_in as a total modulo ULONG_MAX + 1.

ok tb@
usr.bin/compress/gzopen.c