Skip to content

Commit 983a9af

Browse files
committed
Merge branches 'update-bzip2' and 'update-zlib' into pii-master
Signed-off-by: Matt Liberty <mliberty@precisioninno.com>
3 parents 2d74899 + 0497d47 + 749bc49 commit 983a9af

36 files changed

Lines changed: 15262 additions & 4188 deletions

src/misc/bzlib/blocksort.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
This file is part of bzip2/libbzip2, a program and library for
99
lossless, block-sorting data compression.
1010
11-
bzip2/libbzip2 version 1.0.5 of 10 December 2007
12-
Copyright (C) 1996-2007 Julian Seward <jseward@bzip.org>
11+
bzip2/libbzip2 version 1.0.8 of 13 July 2019
12+
Copyright (C) 1996-2019 Julian Seward <jseward@acm.org>
1313
1414
Please read the WARNING, DISCLAIMER and PATENTS sections in the
1515
README file.
@@ -204,9 +204,9 @@ void fallbackQSort3 ( UInt32* fmap,
204204
bhtab [ 0 .. 2+(nblock/32) ] destroyed
205205
*/
206206

207-
#define SET_BH(zz) bhtab[(zz) >> 5] |= (1 << ((zz) & 31))
208-
#define CLEAR_BH(zz) bhtab[(zz) >> 5] &= ~(1 << ((zz) & 31))
209-
#define ISSET_BH(zz) (bhtab[(zz) >> 5] & (1 << ((zz) & 31)))
207+
#define SET_BH(zz) bhtab[(zz) >> 5] |= ((UInt32)1 << ((zz) & 31))
208+
#define CLEAR_BH(zz) bhtab[(zz) >> 5] &= ~((UInt32)1 << ((zz) & 31))
209+
#define ISSET_BH(zz) (bhtab[(zz) >> 5] & ((UInt32)1 << ((zz) & 31)))
210210
#define WORD_BH(zz) bhtab[(zz) >> 5]
211211
#define UNALIGNED_BH(zz) ((zz) & 0x01f)
212212

@@ -276,7 +276,7 @@ void fallbackSort ( UInt32* fmap,
276276
r = -1;
277277
while (1) {
278278

279-
/*-- find the next non-singleton bucket --*/
279+
/*-- find the next non-singleton bucket --*/
280280
k = r + 1;
281281
while (ISSET_BH(k) && UNALIGNED_BH(k)) k++;
282282
if (ISSET_BH(k)) {

src/misc/bzlib/bzlib.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
This file is part of bzip2/libbzip2, a program and library for
99
lossless, block-sorting data compression.
1010
11-
bzip2/libbzip2 version 1.0.5 of 10 December 2007
12-
Copyright (C) 1996-2007 Julian Seward <jseward@bzip.org>
11+
bzip2/libbzip2 version 1.0.8 of 13 July 2019
12+
Copyright (C) 1996-2019 Julian Seward <jseward@acm.org>
1313
1414
Please read the WARNING, DISCLAIMER and PATENTS sections in the
1515
README file.
@@ -54,12 +54,12 @@ void BZ2_bz__AssertH__fail ( int errcode )
5454
fprintf(stderr,
5555
"\n\nbzip2/libbzip2: internal error number %d.\n"
5656
"This is a bug in bzip2/libbzip2, %s.\n"
57-
"Please report it to me at: jseward@bzip.org. If this happened\n"
57+
"Please report it to: bzip2-devel@sourceware.org. If this happened\n"
5858
"when you were using some program which uses libbzip2 as a\n"
5959
"component, you should also report this bug to the author(s)\n"
6060
"of that program. Please make an effort to report this bug;\n"
6161
"timely and accurate bug reports eventually lead to higher\n"
62-
"quality software. Thanks. Julian Seward, 10 December 2007.\n\n",
62+
"quality software. Thanks.\n\n",
6363
errcode,
6464
BZ2_bzlibVersion()
6565
);
@@ -436,7 +436,7 @@ int BZ_API(BZ2_bzCompress) ( bz_stream *strm, int action )
436436
return progress ? BZ_RUN_OK : BZ_PARAM_ERROR;
437437
}
438438
else
439-
if (action == BZ_FLUSH) {
439+
if (action == BZ_FLUSH) {
440440
s->avail_in_expect = strm->avail_in;
441441
s->mode = BZ_M_FLUSHING;
442442
goto preswitch;

src/misc/bzlib/bzlib.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
This file is part of bzip2/libbzip2, a program and library for
99
lossless, block-sorting data compression.
1010
11-
bzip2/libbzip2 version 1.0.5 of 10 December 2007
12-
Copyright (C) 1996-2007 Julian Seward <jseward@bzip.org>
11+
bzip2/libbzip2 version 1.0.8 of 13 July 2019
12+
Copyright (C) 1996-2019 Julian Seward <jseward@acm.org>
1313
1414
Please read the WARNING, DISCLAIMER and PATENTS sections in the
1515
README file.

src/misc/bzlib/bzlib_private.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
This file is part of bzip2/libbzip2, a program and library for
99
lossless, block-sorting data compression.
1010
11-
bzip2/libbzip2 version 1.0.5 of 10 December 2007
12-
Copyright (C) 1996-2007 Julian Seward <jseward@bzip.org>
11+
bzip2/libbzip2 version 1.0.8 of 13 July 2019
12+
Copyright (C) 1996-2019 Julian Seward <jseward@acm.org>
1313
1414
Please read the WARNING, DISCLAIMER and PATENTS sections in the
1515
README file.
@@ -38,7 +38,7 @@ ABC_NAMESPACE_HEADER_START
3838

3939
/*-- General stuff. --*/
4040

41-
#define BZ_VERSION "1.0.5, 10-Dec-2007"
41+
#define BZ_VERSION "1.0.8, 13-Jul-2019"
4242

4343
typedef char Char;
4444
typedef unsigned char Bool;
@@ -483,7 +483,7 @@ typedef
483483

484484
/*-- externs for decompression. --*/
485485

486-
Int32
486+
extern Int32
487487
BZ2_indexIntoF ( Int32, Int32* );
488488

489489
extern Int32

src/misc/bzlib/compress.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
This file is part of bzip2/libbzip2, a program and library for
99
lossless, block-sorting data compression.
1010
11-
bzip2/libbzip2 version 1.0.5 of 10 December 2007
12-
Copyright (C) 1996-2007 Julian Seward <jseward@bzip.org>
11+
bzip2/libbzip2 version 1.0.8 of 13 July 2019
12+
Copyright (C) 1996-2019 Julian Seward <jseward@acm.org>
1313
1414
Please read the WARNING, DISCLAIMER and PATENTS sections in the
1515
README file.
@@ -332,14 +332,14 @@ void sendMTFValues ( EState* s )
332332

333333
/*---
334334
Set up an auxiliary length table which is used to fast-track
335-
the common case (nGroups == 6).
335+
the common case (nGroups == 6).
336336
---*/
337337
if (nGroups == 6) {
338338
for (v = 0; v < alphaSize; v++) {
339339
s->len_pack[v][0] = (s->len[1][v] << 16) | s->len[0][v];
340340
s->len_pack[v][1] = (s->len[3][v] << 16) | s->len[2][v];
341341
s->len_pack[v][2] = (s->len[5][v] << 16) | s->len[4][v];
342-
}
342+
}
343343
}
344344

345345
nSelectors = 0;
@@ -388,7 +388,7 @@ void sendMTFValues ( EState* s )
388388
cost[4] = cost45 & 0xffff; cost[5] = cost45 >> 16;
389389

390390
} else {
391-
/*--- slow version which correctly handles all situations ---*/
391+
/*--- slow version which correctly handles all situations ---*/
392392
for (i = gs; i <= ge; i++) {
393393
UInt16 icv = mtfv[i];
394394
for (t = 0; t < nGroups; t++) cost[t] += s->len[t][icv];
@@ -429,7 +429,7 @@ void sendMTFValues ( EState* s )
429429
# undef BZ_ITUR
430430

431431
} else {
432-
/*--- slow version which correctly handles all situations ---*/
432+
/*--- slow version which correctly handles all situations ---*/
433433
for (i = gs; i <= ge; i++)
434434
s->rfreq[bt][ mtfv[i] ]++;
435435
}
@@ -457,7 +457,7 @@ void sendMTFValues ( EState* s )
457457

458458
AssertH( nGroups < 8, 3002 );
459459
AssertH( nSelectors < 32768 &&
460-
nSelectors <= (2 + (900000 / BZ_G_SIZE)),
460+
nSelectors <= BZ_MAX_SELECTORS,
461461
3003 );
462462

463463

@@ -582,7 +582,7 @@ void sendMTFValues ( EState* s )
582582
# undef BZ_ITAH
583583

584584
} else {
585-
/*--- slow version which correctly handles all situations ---*/
585+
/*--- slow version which correctly handles all situations ---*/
586586
for (i = gs; i <= ge; i++) {
587587
bsW ( s,
588588
s->len [s->selector[selCtr]] [mtfv[i]],

src/misc/bzlib/crctable.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
This file is part of bzip2/libbzip2, a program and library for
99
lossless, block-sorting data compression.
1010
11-
bzip2/libbzip2 version 1.0.5 of 10 December 2007
12-
Copyright (C) 1996-2007 Julian Seward <jseward@bzip.org>
11+
bzip2/libbzip2 version 1.0.8 of 13 July 2019
12+
Copyright (C) 1996-2019 Julian Seward <jseward@acm.org>
1313
1414
Please read the WARNING, DISCLAIMER and PATENTS sections in the
1515
README file.

src/misc/bzlib/decompress.c

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
This file is part of bzip2/libbzip2, a program and library for
99
lossless, block-sorting data compression.
1010
11-
bzip2/libbzip2 version 1.0.5 of 10 December 2007
12-
Copyright (C) 1996-2007 Julian Seward <jseward@bzip.org>
11+
bzip2/libbzip2 version 1.0.8 of 13 July 2019
12+
Copyright (C) 1996-2019 Julian Seward <jseward@acm.org>
1313
1414
Please read the WARNING, DISCLAIMER and PATENTS sections in the
1515
README file.
@@ -292,7 +292,7 @@ Int32 BZ2_decompress ( DState* s )
292292

293293
/*--- Now the selectors ---*/
294294
GET_BITS(BZ_X_SELECTOR_1, nGroups, 3);
295-
if (nGroups < 2 || nGroups > 6) RETURN(BZ_DATA_ERROR);
295+
if (nGroups < 2 || nGroups > BZ_N_GROUPS) RETURN(BZ_DATA_ERROR);
296296
GET_BITS(BZ_X_SELECTOR_2, nSelectors, 15);
297297
if (nSelectors < 1) RETURN(BZ_DATA_ERROR);
298298
for (i = 0; i < nSelectors; i++) {
@@ -303,8 +303,14 @@ Int32 BZ2_decompress ( DState* s )
303303
j++;
304304
if (j >= nGroups) RETURN(BZ_DATA_ERROR);
305305
}
306-
s->selectorMtf[i] = j;
306+
/* Having more than BZ_MAX_SELECTORS doesn't make much sense
307+
since they will never be used, but some implementations might
308+
"round up" the number of selectors, so just ignore those. */
309+
if (i < BZ_MAX_SELECTORS)
310+
s->selectorMtf[i] = j;
307311
}
312+
if (nSelectors > BZ_MAX_SELECTORS)
313+
nSelectors = BZ_MAX_SELECTORS;
308314

309315
/*--- Undo the MTF values for the selectors. ---*/
310316
{
@@ -388,6 +394,13 @@ Int32 BZ2_decompress ( DState* s )
388394
es = -1;
389395
N = 1;
390396
do {
397+
/* Check that N doesn't get too big, so that es doesn't
398+
go negative. The maximum value that can be
399+
RUNA/RUNB encoded is equal to the block size (post
400+
the initial RLE), viz, 900k, so bounding N at 2
401+
million should guard against overflow without
402+
rejecting any legitimate inputs. */
403+
if (N >= 2*1024*1024) RETURN(BZ_DATA_ERROR);
391404
if (nextSym == BZ_RUNA) es = es + (0+1) * N; else
392405
if (nextSym == BZ_RUNB) es = es + (1+1) * N;
393406
N = N * 2;
@@ -492,15 +505,28 @@ Int32 BZ2_decompress ( DState* s )
492505
RETURN(BZ_DATA_ERROR);
493506

494507
/*-- Set up cftab to facilitate generation of T^(-1) --*/
508+
/* Check: unzftab entries in range. */
509+
for (i = 0; i <= 255; i++) {
510+
if (s->unzftab[i] < 0 || s->unzftab[i] > nblock)
511+
RETURN(BZ_DATA_ERROR);
512+
}
513+
/* Actually generate cftab. */
495514
s->cftab[0] = 0;
496515
for (i = 1; i <= 256; i++) s->cftab[i] = s->unzftab[i-1];
497516
for (i = 1; i <= 256; i++) s->cftab[i] += s->cftab[i-1];
517+
/* Check: cftab entries in range. */
498518
for (i = 0; i <= 256; i++) {
499519
if (s->cftab[i] < 0 || s->cftab[i] > nblock) {
500520
/* s->cftab[i] can legitimately be == nblock */
501521
RETURN(BZ_DATA_ERROR);
502522
}
503523
}
524+
/* Check: cftab entries non-descending. */
525+
for (i = 1; i <= 256; i++) {
526+
if (s->cftab[i-1] > s->cftab[i]) {
527+
RETURN(BZ_DATA_ERROR);
528+
}
529+
}
504530

505531
s->state_out_len = 0;
506532
s->state_out_ch = 0;

src/misc/bzlib/huffman.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
This file is part of bzip2/libbzip2, a program and library for
99
lossless, block-sorting data compression.
1010
11-
bzip2/libbzip2 version 1.0.5 of 10 December 2007
12-
Copyright (C) 1996-2007 Julian Seward <jseward@bzip.org>
11+
bzip2/libbzip2 version 1.0.8 of 13 July 2019
12+
Copyright (C) 1996-2019 Julian Seward <jseward@acm.org>
1313
1414
Please read the WARNING, DISCLAIMER and PATENTS sections in the
1515
README file.

src/misc/bzlib/randtable.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
This file is part of bzip2/libbzip2, a program and library for
99
lossless, block-sorting data compression.
1010
11-
bzip2/libbzip2 version 1.0.5 of 10 December 2007
12-
Copyright (C) 1996-2007 Julian Seward <jseward@bzip.org>
11+
bzip2/libbzip2 version 1.0.8 of 13 July 2019
12+
Copyright (C) 1996-2019 Julian Seward <jseward@acm.org>
1313
1414
Please read the WARNING, DISCLAIMER and PATENTS sections in the
1515
README file.

src/misc/zlib/README

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,51 @@
11
ZLIB DATA COMPRESSION LIBRARY
22

3-
zlib 1.2.5 is a general purpose data compression library. All the code is
4-
thread safe. The data format used by the zlib library is described by RFCs
5-
(Request for Comments) 1950 to 1952 in the files
6-
http://www.ietf.org/rfc/rfc1950.txt (zlib format), rfc1951.txt (deflate format)
7-
and rfc1952.txt (gzip format).
3+
zlib 1.3.2 is a general purpose data compression library. All the code is
4+
thread safe (though see the FAQ for caveats). The data format used by the zlib
5+
library is described by RFCs (Request for Comments) 1950 to 1952 at
6+
https://datatracker.ietf.org/doc/html/rfc1950 (zlib format), rfc1951 (deflate
7+
format) and rfc1952 (gzip format).
88

99
All functions of the compression library are documented in the file zlib.h
1010
(volunteer to write man pages welcome, contact zlib@gzip.org). A usage example
11-
of the library is given in the file example.c which also tests that the library
12-
is working correctly. Another example is given in the file minigzip.c. The
13-
compression library itself is composed of all source files except example.c and
14-
minigzip.c.
11+
of the library is given in the file test/example.c which also tests that
12+
the library is working correctly. Another example is given in the file
13+
test/minigzip.c. The compression library itself is composed of all source
14+
files in the root directory.
1515

1616
To compile all files and run the test program, follow the instructions given at
1717
the top of Makefile.in. In short "./configure; make test", and if that goes
18-
well, "make install" should work for most flavors of Unix. For Windows, use one
19-
of the special makefiles in win32/ or contrib/vstudio/ . For VMS, use
18+
well, "make install" should work for most flavors of Unix. For Windows, use
19+
one of the special makefiles in win32/ or contrib/vstudio/ . For VMS, use
2020
make_vms.com.
2121

2222
Questions about zlib should be sent to <zlib@gzip.org>, or to Gilles Vollant
2323
<info@winimage.com> for the Windows DLL version. The zlib home page is
24-
http://zlib.net/ . Before reporting a problem, please check this site to
24+
https://zlib.net/ . Before reporting a problem, please check this site to
2525
verify that you have the latest version of zlib; otherwise get the latest
2626
version and check whether the problem still exists or not.
2727

28-
PLEASE read the zlib FAQ http://zlib.net/zlib_faq.html before asking for help.
28+
PLEASE read the zlib FAQ https://zlib.net/zlib_faq.html before asking for help.
2929

3030
Mark Nelson <markn@ieee.org> wrote an article about zlib for the Jan. 1997
3131
issue of Dr. Dobb's Journal; a copy of the article is available at
32-
http://marknelson.us/1997/01/01/zlib-engine/ .
32+
https://zlib.net/nelson/ .
3333

34-
The changes made in version 1.2.5 are documented in the file ChangeLog.
34+
The changes made in version 1.3.2 are documented in the file ChangeLog.
3535

3636
Unsupported third party contributions are provided in directory contrib/ .
3737

38-
zlib is available in Java using the java.util.zip package, documented at
39-
http://java.sun.com/developer/technicalArticles/Programming/compression/ .
38+
zlib is available in Java using the java.util.zip package. Follow the API
39+
Documentation link at: https://docs.oracle.com/search/?q=java.util.zip .
4040

41-
A Perl interface to zlib written by Paul Marquess <pmqs@cpan.org> is available
42-
at CPAN (Comprehensive Perl Archive Network) sites, including
43-
http://search.cpan.org/~pmqs/IO-Compress-Zlib/ .
41+
A Perl interface to zlib and bzip2 written by Paul Marquess <pmqs@cpan.org>
42+
can be found at https://github.com/pmqs/IO-Compress .
4443

4544
A Python interface to zlib written by A.M. Kuchling <amk@amk.ca> is
4645
available in Python 1.5 and later versions, see
47-
http://www.python.org/doc/lib/module-zlib.html .
46+
https://docs.python.org/3/library/zlib.html .
4847

49-
zlib is built into tcl: http://wiki.tcl.tk/4610 .
48+
zlib is built into tcl: https://wiki.tcl-lang.org/page/zlib .
5049

5150
An experimental package to read and write files in .zip format, written on top
5251
of zlib by Gilles Vollant <info@winimage.com>, is available in the
@@ -64,15 +63,13 @@ Notes for some targets:
6463
- zlib doesn't work with gcc 2.6.3 on a DEC 3000/300LX under OSF/1 2.1 it works
6564
when compiled with cc.
6665

67-
- On Digital Unix 4.0D (formely OSF/1) on AlphaServer, the cc option -std1 is
66+
- On Digital Unix 4.0D (formerly OSF/1) on AlphaServer, the cc option -std1 is
6867
necessary to get gzprintf working correctly. This is done by configure.
6968

7069
- zlib doesn't work on HP-UX 9.05 with some versions of /bin/cc. It works with
7170
other compilers. Use "make test" to check your compiler.
7271

73-
- gzdopen is not supported on RISCOS or BEOS.
74-
75-
- For PalmOs, see http://palmzlib.sourceforge.net/
72+
- For PalmOs, see https://palmzlib.sourceforge.net/
7673

7774

7875
Acknowledgments:
@@ -84,7 +81,7 @@ Acknowledgments:
8481

8582
Copyright notice:
8683

87-
(C) 1995-2010 Jean-loup Gailly and Mark Adler
84+
(C) 1995-2026 Jean-loup Gailly and Mark Adler
8885

8986
This software is provided 'as-is', without any express or implied
9087
warranty. In no event will the authors be held liable for any damages
@@ -108,7 +105,10 @@ Copyright notice:
108105
If you use the zlib library in a product, we would appreciate *not* receiving
109106
lengthy legal documents to sign. The sources are provided for free but without
110107
warranty of any kind. The library has been entirely written by Jean-loup
111-
Gailly and Mark Adler; it does not include third-party code.
108+
Gailly and Mark Adler; it does not include third-party code. We make all
109+
contributions to and distributions of this project solely in our personal
110+
capacity, and are not conveying any rights to any intellectual property of
111+
any third parties.
112112

113113
If you redistribute modified sources, we would appreciate that you include in
114114
the file ChangeLog history information documenting your changes. Please read

0 commit comments

Comments
 (0)