diff options
author | obrien <obrien@FreeBSD.org> | 2005-05-16 18:31:55 +0000 |
---|---|---|
committer | obrien <obrien@FreeBSD.org> | 2005-05-16 18:31:55 +0000 |
commit | 344ba35988e53bba3654f363d1bdcc39430247df (patch) | |
tree | 1ab456aa9146f4b57bf41375952059b5cceae392 /contrib/bzip2/decompress.c | |
parent | b718740c2fa9f3e14e09fba90eca26f829b7d43a (diff) | |
download | FreeBSD-src-344ba35988e53bba3654f363d1bdcc39430247df.zip FreeBSD-src-344ba35988e53bba3654f363d1bdcc39430247df.tar.gz |
Virgin import (trimmed) of Bzip2 version 1.0.3.
Diffstat (limited to 'contrib/bzip2/decompress.c')
-rw-r--r-- | contrib/bzip2/decompress.c | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/contrib/bzip2/decompress.c b/contrib/bzip2/decompress.c index e921347..81c3d2c 100644 --- a/contrib/bzip2/decompress.c +++ b/contrib/bzip2/decompress.c @@ -8,7 +8,7 @@ This file is a part of bzip2 and/or libbzip2, a program and library for lossless, block-sorting data compression. - Copyright (C) 1996-2002 Julian R Seward. All rights reserved. + Copyright (C) 1996-2005 Julian R Seward. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions @@ -42,7 +42,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. Julian Seward, Cambridge, UK. - jseward@acm.org + jseward@bzip.org bzip2/libbzip2 version 1.0 of 21 March 2000 This program is based on (at least) the work of: @@ -524,17 +524,23 @@ Int32 BZ2_decompress ( DState* s ) if (s->origPtr < 0 || s->origPtr >= nblock) RETURN(BZ_DATA_ERROR); + /*-- Set up cftab to facilitate generation of T^(-1) --*/ + s->cftab[0] = 0; + for (i = 1; i <= 256; i++) s->cftab[i] = s->unzftab[i-1]; + for (i = 1; i <= 256; i++) s->cftab[i] += s->cftab[i-1]; + for (i = 0; i <= 256; i++) { + if (s->cftab[i] < 0 || s->cftab[i] > nblock) { + /* s->cftab[i] can legitimately be == nblock */ + RETURN(BZ_DATA_ERROR); + } + } + s->state_out_len = 0; s->state_out_ch = 0; BZ_INITIALISE_CRC ( s->calculatedBlockCRC ); s->state = BZ_X_OUTPUT; if (s->verbosity >= 2) VPrintf0 ( "rt+rld" ); - /*-- Set up cftab to facilitate generation of T^(-1) --*/ - s->cftab[0] = 0; - for (i = 1; i <= 256; i++) s->cftab[i] = s->unzftab[i-1]; - for (i = 1; i <= 256; i++) s->cftab[i] += s->cftab[i-1]; - if (s->smallDecompress) { /*-- Make a copy of cftab, used in generation of T --*/ |