uncompress: Avoid reading an extra byte

When reading the next code in a stream, avoid reading an extra byte if
we're going to throw it away. When there's no more bits to extract from
the stream, bits will be 0 and we'll mask the read byte with 0 anyway.
At worst, this will avoid reading one past the end of gbuf array (which
is not possible in well formed streams).

PR: 127912
Reviewed by:	emaste
Differential Revision:	https://reviews.freebsd.org/D47041
This commit is contained in:
David Jones authored and Warner Losh committed 2024-10-11 09:50:09 -06:00
1 parent 6cde8f3ef7
commit 818c7b769a
1 file changed
+1
+1
View File
@@ -620,6 +620,7 @@ getcode(struct s_zstate *zs)
}
/* High order bits. */
if (bits > 0)
gcode |= (*bp & rmask[bits]) << r_off;
roffset += n_bits;