Skip to content

Commit 5d578d9

Browse files
committed
Update zlib to 1.3.1
Issue #19450 Signed-off-by: Peter Shipton <[email protected]>
1 parent dea130d commit 5d578d9

13 files changed

+115
-78
lines changed

longabout.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -189,8 +189,8 @@ <h4>libFFI pre 3.5</h4>
189189
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
190190
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
191191
<p>
192-
<h4>zlib 1.3</h4>
193-
(C) 1995-2023 Jean-loup Gailly and Mark Adler
192+
<h4>zlib 1.3.1</h4>
193+
(C) 1995-2024 Jean-loup Gailly and Mark Adler
194194
<p>
195195
This software is provided 'as-is', without any express or implied
196196
warranty. In no event will the authors be held liable for any damages

runtime/include/about.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,13 @@ <h3>Third Party Content</h3>
4040
Content directly from the Eclipse Foundation, the following is provided for informational purposes only, and you
4141
should look to the Redistributor's license for terms and conditions of use.</p>
4242

43-
<h3>zlib 1.3</h3>
43+
<h3>zlib 1.3.1</h3>
4444

4545
<p>zlib general purpose compression library obtained from https://zlib.net/</p>
4646

4747
<p>The software is modified from the original version.</p>
4848

49-
<p>Copyright (C) 1995-2023 Jean-loup Gailly and Mark Adler</p>
49+
<p>Copyright (C) 1995-2024 Jean-loup Gailly and Mark Adler</p>
5050

5151
<p>This software is
5252
provided 'as-is', without any express or implied warranty. In no event will the

runtime/include/zconf.h

+1-9
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* zconf.h -- configuration of the zlib compression library
2-
* Copyright (C) 1995-2016 Jean-loup Gailly, Mark Adler
2+
* Copyright (C) 1995-2024 Jean-loup Gailly, Mark Adler
33
* For conditions of distribution and use, see copyright notice in zlib.h
44
*/
55

@@ -305,14 +305,6 @@
305305
# endif
306306
#endif
307307

308-
#ifndef Z_ARG /* function prototypes for stdarg */
309-
# if defined(STDC) || defined(Z_HAVE_STDARG_H)
310-
# define Z_ARG(args) args
311-
# else
312-
# define Z_ARG(args) ()
313-
# endif
314-
#endif
315-
316308
/* The following definitions for FAR are needed only for MSDOS mixed
317309
* model programming (small or medium model with some far allocations).
318310
* This was tested only with MSC; for other MSDOS compilers you may have

runtime/include/zlib.h

+11-11
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* zlib.h -- interface of the 'zlib' general purpose compression library
2-
version 1.3, August 18th, 2023
2+
version 1.3.1, January 22nd, 2024
33
4-
Copyright (C) 1995-2023 Jean-loup Gailly and Mark Adler
4+
Copyright (C) 1995-2024 Jean-loup Gailly and Mark Adler
55
66
This software is provided 'as-is', without any express or implied
77
warranty. In no event will the authors be held liable for any damages
@@ -37,11 +37,11 @@
3737
extern "C" {
3838
#endif
3939

40-
#define ZLIB_VERSION "1.3"
41-
#define ZLIB_VERNUM 0x1300
40+
#define ZLIB_VERSION "1.3.1"
41+
#define ZLIB_VERNUM 0x1310
4242
#define ZLIB_VER_MAJOR 1
4343
#define ZLIB_VER_MINOR 3
44-
#define ZLIB_VER_REVISION 0
44+
#define ZLIB_VER_REVISION 1
4545
#define ZLIB_VER_SUBREVISION 0
4646

4747
/*
@@ -936,10 +936,10 @@ ZEXTERN int ZEXPORT inflateSync(z_streamp strm);
936936
inflateSync returns Z_OK if a possible full flush point has been found,
937937
Z_BUF_ERROR if no more input was provided, Z_DATA_ERROR if no flush point
938938
has been found, or Z_STREAM_ERROR if the stream structure was inconsistent.
939-
In the success case, the application may save the current current value of
940-
total_in which indicates where valid compressed data was found. In the
941-
error case, the application may repeatedly call inflateSync, providing more
942-
input each time, until success or end of the input data.
939+
In the success case, the application may save the current value of total_in
940+
which indicates where valid compressed data was found. In the error case,
941+
the application may repeatedly call inflateSync, providing more input each
942+
time, until success or end of the input data.
943943
*/
944944

945945
ZEXTERN int ZEXPORT inflateCopy(z_streamp dest,
@@ -1758,14 +1758,14 @@ ZEXTERN uLong ZEXPORT crc32_combine(uLong crc1, uLong crc2, z_off_t len2);
17581758
seq1 and seq2 with lengths len1 and len2, CRC-32 check values were
17591759
calculated for each, crc1 and crc2. crc32_combine() returns the CRC-32
17601760
check value of seq1 and seq2 concatenated, requiring only crc1, crc2, and
1761-
len2.
1761+
len2. len2 must be non-negative.
17621762
*/
17631763

17641764
/*
17651765
ZEXTERN uLong ZEXPORT crc32_combine_gen(z_off_t len2);
17661766
17671767
Return the operator corresponding to length len2, to be used with
1768-
crc32_combine_op().
1768+
crc32_combine_op(). len2 must be non-negative.
17691769
*/
17701770

17711771
ZEXTERN uLong ZEXPORT crc32_combine_op(uLong crc1, uLong crc2, uLong op);

runtime/zlib/about.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,13 @@ <h3>Third Party Content</h3>
3939
Content directly from the Eclipse Foundation, the following is provided for informational purposes only, and you
4040
should look to the Redistributor's license for terms and conditions of use.</p>
4141

42-
<h3>zlib 1.3</h3>
42+
<h3>zlib 1.3.1</h3>
4343

4444
<p>zlib general purpose compression library obtained from http://zlib.net/</p>
4545

4646
<p>The software is modified from the original version.</p>
4747

48-
<p>Copyright (C) 1995-2023 Jean-loup Gailly and Mark Adler</p>
48+
<p>Copyright (C) 1995-2024 Jean-loup Gailly and Mark Adler</p>
4949

5050
<p>This software is
5151
provided 'as-is', without any express or implied warranty. In no event will the

runtime/zlib/deflate.c

+36-11
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* deflate.c -- compress data using the deflation algorithm
2-
* Copyright (C) 1995-2023 Jean-loup Gailly and Mark Adler
2+
* Copyright (C) 1995-2024 Jean-loup Gailly and Mark Adler
33
* For conditions of distribution and use, see copyright notice in zlib.h
44
*/
55

@@ -52,7 +52,7 @@
5252
#include "deflate.h"
5353

5454
const char deflate_copyright[] =
55-
" deflate 1.3 Copyright 1995-2023 Jean-loup Gailly and Mark Adler ";
55+
" deflate 1.3.1 Copyright 1995-2024 Jean-loup Gailly and Mark Adler ";
5656
/*
5757
If you use the zlib library in a product, an acknowledgment is welcome
5858
in the documentation of your product. If for some reason you cannot
@@ -493,7 +493,7 @@ int ZEXPORT deflateInit2_(z_streamp strm, int level, int method,
493493
* symbols from which it is being constructed.
494494
*/
495495

496-
s->pending_buf = (uchf *) ZALLOC(strm, s->lit_bufsize, 4);
496+
s->pending_buf = (uchf *) ZALLOC(strm, s->lit_bufsize, LIT_BUFS);
497497
s->pending_buf_size = (ulg)s->lit_bufsize * 4;
498498

499499
if (s->window == Z_NULL || s->prev == Z_NULL || s->head == Z_NULL ||
@@ -503,8 +503,14 @@ int ZEXPORT deflateInit2_(z_streamp strm, int level, int method,
503503
deflateEnd (strm);
504504
return Z_MEM_ERROR;
505505
}
506+
#ifdef LIT_MEM
507+
s->d_buf = (ushf *)(s->pending_buf + (s->lit_bufsize << 1));
508+
s->l_buf = s->pending_buf + (s->lit_bufsize << 2);
509+
s->sym_end = s->lit_bufsize - 1;
510+
#else
506511
s->sym_buf = s->pending_buf + s->lit_bufsize;
507512
s->sym_end = (s->lit_bufsize - 1) * 3;
513+
#endif
508514
/* We avoid equality with lit_bufsize*3 because of wraparound at 64K
509515
* on 16 bit machines and because stored blocks are restricted to
510516
* 64K-1 bytes.
@@ -720,9 +726,15 @@ int ZEXPORT deflatePrime(z_streamp strm, int bits, int value) {
720726

721727
if (deflateStateCheck(strm)) return Z_STREAM_ERROR;
722728
s = strm->state;
729+
#ifdef LIT_MEM
730+
if (bits < 0 || bits > 16 ||
731+
(uchf *)s->d_buf < s->pending_out + ((Buf_size + 7) >> 3))
732+
return Z_BUF_ERROR;
733+
#else
723734
if (bits < 0 || bits > 16 ||
724735
s->sym_buf < s->pending_out + ((Buf_size + 7) >> 3))
725736
return Z_BUF_ERROR;
737+
#endif
726738
do {
727739
put = Buf_size - s->bi_valid;
728740
if (put > bits)
@@ -1294,7 +1306,7 @@ int ZEXPORT deflateCopy(z_streamp dest, z_streamp source) {
12941306
ds->window = (Bytef *) ZALLOC(dest, ds->w_size, 2*sizeof(Byte));
12951307
ds->prev = (Posf *) ZALLOC(dest, ds->w_size, sizeof(Pos));
12961308
ds->head = (Posf *) ZALLOC(dest, ds->hash_size, sizeof(Pos));
1297-
ds->pending_buf = (uchf *) ZALLOC(dest, ds->lit_bufsize, 4);
1309+
ds->pending_buf = (uchf *) ZALLOC(dest, ds->lit_bufsize, LIT_BUFS);
12981310

12991311
if (ds->window == Z_NULL || ds->prev == Z_NULL || ds->head == Z_NULL ||
13001312
ds->pending_buf == Z_NULL) {
@@ -1305,10 +1317,15 @@ int ZEXPORT deflateCopy(z_streamp dest, z_streamp source) {
13051317
zmemcpy(ds->window, ss->window, ds->w_size * 2 * sizeof(Byte));
13061318
zmemcpy((voidpf)ds->prev, (voidpf)ss->prev, ds->w_size * sizeof(Pos));
13071319
zmemcpy((voidpf)ds->head, (voidpf)ss->head, ds->hash_size * sizeof(Pos));
1308-
zmemcpy(ds->pending_buf, ss->pending_buf, (uInt)ds->pending_buf_size);
1320+
zmemcpy(ds->pending_buf, ss->pending_buf, ds->lit_bufsize * LIT_BUFS);
13091321

13101322
ds->pending_out = ds->pending_buf + (ss->pending_out - ss->pending_buf);
1323+
#ifdef LIT_MEM
1324+
ds->d_buf = (ushf *)(ds->pending_buf + (ds->lit_bufsize << 1));
1325+
ds->l_buf = ds->pending_buf + (ds->lit_bufsize << 2);
1326+
#else
13111327
ds->sym_buf = ds->pending_buf + ds->lit_bufsize;
1328+
#endif
13121329

13131330
ds->l_desc.dyn_tree = ds->dyn_ltree;
13141331
ds->d_desc.dyn_tree = ds->dyn_dtree;
@@ -1539,13 +1556,21 @@ local uInt longest_match(deflate_state *s, IPos cur_match) {
15391556
*/
15401557
local void check_match(deflate_state *s, IPos start, IPos match, int length) {
15411558
/* check that the match is indeed a match */
1542-
if (zmemcmp(s->window + match,
1543-
s->window + start, length) != EQUAL) {
1544-
fprintf(stderr, " start %u, match %u, length %d\n",
1545-
start, match, length);
1559+
Bytef *back = s->window + (int)match, *here = s->window + start;
1560+
IPos len = length;
1561+
if (match == (IPos)-1) {
1562+
/* match starts one byte before the current window -- just compare the
1563+
subsequent length-1 bytes */
1564+
back++;
1565+
here++;
1566+
len--;
1567+
}
1568+
if (zmemcmp(back, here, len) != EQUAL) {
1569+
fprintf(stderr, " start %u, match %d, length %d\n",
1570+
start, (int)match, length);
15461571
do {
1547-
fprintf(stderr, "%c%c", s->window[match++], s->window[start++]);
1548-
} while (--length != 0);
1572+
fprintf(stderr, "(%02x %02x)", *back++, *here++);
1573+
} while (--len != 0);
15491574
z_error("invalid match");
15501575
}
15511576
if (z_verbose > 1) {

runtime/zlib/deflate.h

+33-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* deflate.h -- internal compression state
2-
* Copyright (C) 1995-2018 Jean-loup Gailly
2+
* Copyright (C) 1995-2024 Jean-loup Gailly
33
* For conditions of distribution and use, see copyright notice in zlib.h
44
*/
55

@@ -26,6 +26,10 @@
2626
# define GZIP
2727
#endif
2828

29+
/* define LIT_MEM to slightly increase the speed of deflate (order 1% to 2%) at
30+
the cost of a larger memory footprint */
31+
/* #define LIT_MEM */
32+
2933
/* ===========================================================================
3034
* Internal compression state.
3135
*/
@@ -220,7 +224,14 @@ typedef struct internal_state {
220224
/* Depth of each subtree used as tie breaker for trees of equal frequency
221225
*/
222226

227+
#ifdef LIT_MEM
228+
# define LIT_BUFS 5
229+
ushf *d_buf; /* buffer for distances */
230+
uchf *l_buf; /* buffer for literals/lengths */
231+
#else
232+
# define LIT_BUFS 4
223233
uchf *sym_buf; /* buffer for distances and literals/lengths */
234+
#endif
224235

225236
uInt lit_bufsize;
226237
/* Size of match buffer for literals/lengths. There are 4 reasons for
@@ -242,7 +253,7 @@ typedef struct internal_state {
242253
* - I can't count above 4
243254
*/
244255

245-
uInt sym_next; /* running index in sym_buf */
256+
uInt sym_next; /* running index in symbol buffer */
246257
uInt sym_end; /* symbol table full when sym_next reaches this */
247258

248259
ulg opt_len; /* bit length of current block with optimal trees */
@@ -321,6 +332,25 @@ void ZLIB_INTERNAL _tr_stored_block(deflate_state *s, charf *buf,
321332
extern const uch ZLIB_INTERNAL _dist_code[];
322333
#endif
323334

335+
#ifdef LIT_MEM
336+
# define _tr_tally_lit(s, c, flush) \
337+
{ uch cc = (c); \
338+
s->d_buf[s->sym_next] = 0; \
339+
s->l_buf[s->sym_next++] = cc; \
340+
s->dyn_ltree[cc].Freq++; \
341+
flush = (s->sym_next == s->sym_end); \
342+
}
343+
# define _tr_tally_dist(s, distance, length, flush) \
344+
{ uch len = (uch)(length); \
345+
ush dist = (ush)(distance); \
346+
s->d_buf[s->sym_next] = dist; \
347+
s->l_buf[s->sym_next++] = len; \
348+
dist--; \
349+
s->dyn_ltree[_length_code[len]+LITERALS+1].Freq++; \
350+
s->dyn_dtree[d_code(dist)].Freq++; \
351+
flush = (s->sym_next == s->sym_end); \
352+
}
353+
#else
324354
# define _tr_tally_lit(s, c, flush) \
325355
{ uch cc = (c); \
326356
s->sym_buf[s->sym_next++] = 0; \
@@ -340,6 +370,7 @@ void ZLIB_INTERNAL _tr_stored_block(deflate_state *s, charf *buf,
340370
s->dyn_dtree[d_code(dist)].Freq++; \
341371
flush = (s->sym_next == s->sym_end); \
342372
}
373+
#endif
343374
#else
344375
# define _tr_tally_lit(s, c, flush) flush = _tr_tally(s, 0, c)
345376
# define _tr_tally_dist(s, distance, length, flush) \

runtime/zlib/gzguts.h

+2-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* gzguts.h -- zlib internal header definitions for gz* operations
2-
* Copyright (C) 2004-2019 Mark Adler
2+
* Copyright (C) 2004-2024 Mark Adler
33
* For conditions of distribution and use, see copyright notice in zlib.h
44
*/
55

@@ -210,9 +210,5 @@ char ZLIB_INTERNAL *gz_strwinerror(DWORD error);
210210
/* GT_OFF(x), where x is an unsigned value, is true if x > maximum z_off64_t
211211
value -- needed when comparing unsigned to z_off64_t, which is signed
212212
(possible z_off64_t types off_t, off64_t, and long are all signed) */
213-
#ifdef INT_MAX
214-
# define GT_OFF(x) (sizeof(int) == sizeof(z_off64_t) && (x) > INT_MAX)
215-
#else
216213
unsigned ZLIB_INTERNAL gz_intmax(void);
217-
# define GT_OFF(x) (sizeof(int) == sizeof(z_off64_t) && (x) > gz_intmax())
218-
#endif
214+
#define GT_OFF(x) (sizeof(int) == sizeof(z_off64_t) && (x) > gz_intmax())

runtime/zlib/inflate.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1387,7 +1387,7 @@ int ZEXPORT inflateSync(z_streamp strm) {
13871387
/* if first time, start search in bit buffer */
13881388
if (state->mode != SYNC) {
13891389
state->mode = SYNC;
1390-
state->hold <<= state->bits & 7;
1390+
state->hold >>= state->bits & 7;
13911391
state->bits -= state->bits & 7;
13921392
len = 0;
13931393
while (state->bits >= 8) {

runtime/zlib/inftrees.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* inftrees.c -- generate Huffman trees for efficient decoding
2-
* Copyright (C) 1995-2023 Mark Adler
2+
* Copyright (C) 1995-2024 Mark Adler
33
* For conditions of distribution and use, see copyright notice in zlib.h
44
*/
55

@@ -9,7 +9,7 @@
99
#define MAXBITS 15
1010

1111
const char inflate_copyright[] =
12-
" inflate 1.3 Copyright 1995-2023 Mark Adler ";
12+
" inflate 1.3.1 Copyright 1995-2024 Mark Adler ";
1313
/*
1414
If you use the zlib library in a product, an acknowledgment is welcome
1515
in the documentation of your product. If for some reason you cannot
@@ -57,7 +57,7 @@ int ZLIB_INTERNAL inflate_table(codetype type, unsigned short FAR *lens,
5757
35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0};
5858
static const unsigned short lext[31] = { /* Length codes 257..285 extra */
5959
16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18,
60-
19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 198, 203};
60+
19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 203, 77};
6161
static const unsigned short dbase[32] = { /* Distance codes 0..29 base */
6262
1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,
6363
257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,

runtime/zlib/inftrees.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ typedef struct {
4141
examples/enough.c found in the zlib distribution. The arguments to that
4242
program are the number of symbols, the initial root table size, and the
4343
maximum bit length of a code. "enough 286 9 15" for literal/length codes
44-
returns returns 852, and "enough 30 6 15" for distance codes returns 592.
45-
The initial root table size (9 or 6) is found in the fifth argument of the
44+
returns 852, and "enough 30 6 15" for distance codes returns 592. The
45+
initial root table size (9 or 6) is found in the fifth argument of the
4646
inflate_table() calls in inflate.c and infback.c. If the root table size is
4747
changed, then these maximum sizes would be need to be recalculated and
4848
updated. */

0 commit comments

Comments
 (0)