From bc92bf4ff81ccb645c1d8d0dc65e9708b538f5a9 Mon Sep 17 00:00:00 2001 From: Nigel Tao Date: Thu, 3 Aug 2017 10:15:55 +1000 Subject: [PATCH] Fix C decode_huffman's exit with excess high bits. --- script/puffs-flate-decoder-decode-huffman.c | 1 + 1 file changed, 1 insertion(+) diff --git a/script/puffs-flate-decoder-decode-huffman.c b/script/puffs-flate-decoder-decode-huffman.c index 3e2d1089..1ff351ad 100644 --- a/script/puffs-flate-decoder-decode-huffman.c +++ b/script/puffs-flate-decoder-decode-huffman.c @@ -223,6 +223,7 @@ end: for (; n_bits >= 8; n_bits -= 8) { psrc--; } + bits &= (((uint32_t)(1)) << n_bits) - 1; // Save contextual state. a_dst.buf->wi = pdst - a_dst.buf->ptr;