aboutsummaryrefslogtreecommitdiff
path: root/lib/bunzip.c
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2007-01-17 16:31:23 -0500
committerRob Landley <rob@landley.net>2007-01-17 16:31:23 -0500
commitcac0ab034cbaba11e3cb5d9191589fac0ad4f1fc (patch)
treec91e3ce2563ce90b8f9e3a39e62c46142292ea16 /lib/bunzip.c
parent0dc2d4980d9c42f6505d45f520b655d443ff9152 (diff)
downloadtoybox-cac0ab034cbaba11e3cb5d9191589fac0ad4f1fc.tar.gz
Fix off by one error in a test.
Diffstat (limited to 'lib/bunzip.c')
-rw-r--r--lib/bunzip.c4
1 files changed, 3 insertions, 1 deletions
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++
}