From cac0ab034cbaba11e3cb5d9191589fac0ad4f1fc Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Wed, 17 Jan 2007 16:31:23 -0500 Subject: Fix off by one error in a test. --- lib/bunzip.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/bunzip.c b/lib/bunzip.c index 5c3b842b..01daa783 100644 --- a/lib/bunzip.c +++ b/lib/bunzip.c @@ -197,7 +197,9 @@ int read_bunzip_data(bunzip_data *bd) t = get_bits(bd, 5); for (i = 0; i < symCount; i++) { for(;;) { - if (MAX_HUFCODE_BITS < (unsigned)t-1) return RETVAL_DATA_ERROR; + // !t || t > MAX_HUFCODE_BITS in one test. + if (MAX_HUFCODE_BITS-1 < (unsigned)t-1) + return RETVAL_DATA_ERROR; if(!get_bits(bd, 1)) break; // Stop yet? t += (1 - 2*get_bits(bd, 1)); // bit ? t-- : t++ } -- cgit v1.2.3