diff options
Diffstat (limited to 'decompress.c')
-rw-r--r-- | decompress.c | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/decompress.c b/decompress.c index e921347..81c3d2c 100644 --- a/decompress.c +++ b/decompress.c | |||
@@ -8,7 +8,7 @@ | |||
8 | This file is a part of bzip2 and/or libbzip2, a program and | 8 | This file is a part of bzip2 and/or libbzip2, a program and |
9 | library for lossless, block-sorting data compression. | 9 | library for lossless, block-sorting data compression. |
10 | 10 | ||
11 | Copyright (C) 1996-2002 Julian R Seward. All rights reserved. | 11 | Copyright (C) 1996-2005 Julian R Seward. All rights reserved. |
12 | 12 | ||
13 | Redistribution and use in source and binary forms, with or without | 13 | Redistribution and use in source and binary forms, with or without |
14 | modification, are permitted provided that the following conditions | 14 | modification, are permitted provided that the following conditions |
@@ -42,7 +42,7 @@ | |||
42 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 42 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
43 | 43 | ||
44 | Julian Seward, Cambridge, UK. | 44 | Julian Seward, Cambridge, UK. |
45 | jseward@acm.org | 45 | jseward@bzip.org |
46 | bzip2/libbzip2 version 1.0 of 21 March 2000 | 46 | bzip2/libbzip2 version 1.0 of 21 March 2000 |
47 | 47 | ||
48 | This program is based on (at least) the work of: | 48 | This program is based on (at least) the work of: |
@@ -524,17 +524,23 @@ Int32 BZ2_decompress ( DState* s ) | |||
524 | if (s->origPtr < 0 || s->origPtr >= nblock) | 524 | if (s->origPtr < 0 || s->origPtr >= nblock) |
525 | RETURN(BZ_DATA_ERROR); | 525 | RETURN(BZ_DATA_ERROR); |
526 | 526 | ||
527 | /*-- Set up cftab to facilitate generation of T^(-1) --*/ | ||
528 | s->cftab[0] = 0; | ||
529 | for (i = 1; i <= 256; i++) s->cftab[i] = s->unzftab[i-1]; | ||
530 | for (i = 1; i <= 256; i++) s->cftab[i] += s->cftab[i-1]; | ||
531 | for (i = 0; i <= 256; i++) { | ||
532 | if (s->cftab[i] < 0 || s->cftab[i] > nblock) { | ||
533 | /* s->cftab[i] can legitimately be == nblock */ | ||
534 | RETURN(BZ_DATA_ERROR); | ||
535 | } | ||
536 | } | ||
537 | |||
527 | s->state_out_len = 0; | 538 | s->state_out_len = 0; |
528 | s->state_out_ch = 0; | 539 | s->state_out_ch = 0; |
529 | BZ_INITIALISE_CRC ( s->calculatedBlockCRC ); | 540 | BZ_INITIALISE_CRC ( s->calculatedBlockCRC ); |
530 | s->state = BZ_X_OUTPUT; | 541 | s->state = BZ_X_OUTPUT; |
531 | if (s->verbosity >= 2) VPrintf0 ( "rt+rld" ); | 542 | if (s->verbosity >= 2) VPrintf0 ( "rt+rld" ); |
532 | 543 | ||
533 | /*-- Set up cftab to facilitate generation of T^(-1) --*/ | ||
534 | s->cftab[0] = 0; | ||
535 | for (i = 1; i <= 256; i++) s->cftab[i] = s->unzftab[i-1]; | ||
536 | for (i = 1; i <= 256; i++) s->cftab[i] += s->cftab[i-1]; | ||
537 | |||
538 | if (s->smallDecompress) { | 544 | if (s->smallDecompress) { |
539 | 545 | ||
540 | /*-- Make a copy of cftab, used in generation of T --*/ | 546 | /*-- Make a copy of cftab, used in generation of T --*/ |