Skip to content

Commit 1a2eebf

Browse files
committed
Update zlib to the 1.2.10 release
Changes in 1.2.10 (2 Jan 2017) - Avoid warnings on snprintf() return value - Fix bug in deflate_stored() for zero-length input - Fix bug in gzwrite.c that produced corrupt gzip files - Remove files to be installed before copying them in Makefile.in - Add warnings when compiling with assembler code Changes in 1.2.9 (31 Dec 2016) - Fix contrib/minizip to permit unzipping with desktop API [Zouzou] - Improve contrib/blast to return unused bytes - Assure that gzoffset() is correct when appending - Improve compress() and uncompress() to support large lengths - Fix bug in test/example.c where error code not saved - Remedy Coverity warning [Randers-Pehrson] - Improve speed of gzprintf() in transparent mode - Fix inflateInit2() bug when windowBits is 16 or 32 - Change DEBUG macro to ZLIB_DEBUG - Avoid uninitialized access by gzclose_w() - Allow building zlib outside of the source directory - Fix bug that accepted invalid zlib header when windowBits is zero - Fix gzseek() problem on MinGW due to buggy _lseeki64 there - Loop on write() calls in gzwrite.c in case of non-blocking I/O - Add --warn (-w) option to ./configure for more compiler warnings - Reject a window size of 256 bytes if not using the zlib wrapper - Fix bug when level 0 used with Z_HUFFMAN or Z_RLE - Add --debug (-d) option to ./configure to define ZLIB_DEBUG - Fix bugs in creating a very large gzip header - Add uncompress2() function, which returns the input size used - Assure that deflateParams() will not switch functions mid-block - Dramatically speed up deflation for level 0 (storing) - Add gzfread(), duplicating the interface of fread() - Add gzfwrite(), duplicating the interface of fwrite() - Add deflateGetDictionary() function - Use snprintf() for later versions of Microsoft C - Fix *Init macros to use z_ prefix when requested - Replace as400 with os400 for OS/400 support [Monnerat] - Add crc32_z() and adler32_z() functions with size_t lengths - Update Visual Studio project files [AraHaan]
1 parent 4870429 commit 1a2eebf

24 files changed

+2598
-1556
lines changed

etc/c/zlib.d

Lines changed: 950 additions & 558 deletions
Large diffs are not rendered by default.

etc/c/zlib/ChangeLog

Lines changed: 45 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,49 @@
11

22
ChangeLog file for zlib
33

4+
Changes in 1.2.10 (2 Jan 2017)
5+
- Avoid warnings on snprintf() return value
6+
- Fix bug in deflate_stored() for zero-length input
7+
- Fix bug in gzwrite.c that produced corrupt gzip files
8+
- Remove files to be installed before copying them in Makefile.in
9+
- Add warnings when compiling with assembler code
10+
11+
Changes in 1.2.9 (31 Dec 2016)
12+
- Fix contrib/minizip to permit unzipping with desktop API [Zouzou]
13+
- Improve contrib/blast to return unused bytes
14+
- Assure that gzoffset() is correct when appending
15+
- Improve compress() and uncompress() to support large lengths
16+
- Fix bug in test/example.c where error code not saved
17+
- Remedy Coverity warning [Randers-Pehrson]
18+
- Improve speed of gzprintf() in transparent mode
19+
- Fix inflateInit2() bug when windowBits is 16 or 32
20+
- Change DEBUG macro to ZLIB_DEBUG
21+
- Avoid uninitialized access by gzclose_w()
22+
- Allow building zlib outside of the source directory
23+
- Fix bug that accepted invalid zlib header when windowBits is zero
24+
- Fix gzseek() problem on MinGW due to buggy _lseeki64 there
25+
- Loop on write() calls in gzwrite.c in case of non-blocking I/O
26+
- Add --warn (-w) option to ./configure for more compiler warnings
27+
- Reject a window size of 256 bytes if not using the zlib wrapper
28+
- Fix bug when level 0 used with Z_HUFFMAN or Z_RLE
29+
- Add --debug (-d) option to ./configure to define ZLIB_DEBUG
30+
- Fix bugs in creating a very large gzip header
31+
- Add uncompress2() function, which returns the input size used
32+
- Assure that deflateParams() will not switch functions mid-block
33+
- Dramatically speed up deflation for level 0 (storing)
34+
- Add gzfread(), duplicating the interface of fread()
35+
- Add gzfwrite(), duplicating the interface of fwrite()
36+
- Add deflateGetDictionary() function
37+
- Use snprintf() for later versions of Microsoft C
38+
- Fix *Init macros to use z_ prefix when requested
39+
- Replace as400 with os400 for OS/400 support [Monnerat]
40+
- Add crc32_z() and adler32_z() functions with size_t lengths
41+
- Update Visual Studio project files [AraHaan]
42+
443
Changes in 1.2.8 (28 Apr 2013)
544
- Update contrib/minizip/iowin32.c for Windows RT [Vollant]
645
- Do not force Z_CONST for C++
7-
- Clean up contrib/vstudio [Ro�]
46+
- Clean up contrib/vstudio [Roß]
847
- Correct spelling error in zlib.h
948
- Fix mixed line endings in contrib/vstudio
1049

@@ -34,7 +73,7 @@ Changes in 1.2.7.1 (24 Mar 2013)
3473
- Clean up the usage of z_const and respect const usage within zlib
3574
- Clean up examples/gzlog.[ch] comparisons of different types
3675
- Avoid shift equal to bits in type (caused endless loop)
37-
- Fix unintialized value bug in gzputc() introduced by const patches
76+
- Fix uninitialized value bug in gzputc() introduced by const patches
3877
- Fix memory allocation error in examples/zran.c [Nor]
3978
- Fix bug where gzopen(), gzclose() would write an empty file
4079
- Fix bug in gzclose() when gzwrite() runs out of memory
@@ -194,7 +233,7 @@ Changes in 1.2.5.2 (17 Dec 2011)
194233
- Add a transparent write mode to gzopen() when 'T' is in the mode
195234
- Update python link in zlib man page
196235
- Get inffixed.h and MAKEFIXED result to match
197-
- Add a ./config --solo option to make zlib subset with no libary use
236+
- Add a ./config --solo option to make zlib subset with no library use
198237
- Add undocumented inflateResetKeep() function for CAB file decoding
199238
- Add --cover option to ./configure for gcc coverage testing
200239
- Add #define ZLIB_CONST option to use const in the z_stream interface
@@ -564,7 +603,7 @@ Changes in 1.2.3.1 (16 August 2006)
564603
- Update make_vms.com [Zinser]
565604
- Use -fPIC for shared build in configure [Teredesai, Nicholson]
566605
- Use only major version number for libz.so on IRIX and OSF1 [Reinholdtsen]
567-
- Use fdopen() (not _fdopen()) for Interix in zutil.h [B�ck]
606+
- Use fdopen() (not _fdopen()) for Interix in zutil.h [Bäck]
568607
- Add some FAQ entries about the contrib directory
569608
- Update the MVS question in the FAQ
570609
- Avoid extraneous reads after EOF in gzio.c [Brown]
@@ -1178,7 +1217,7 @@ Changes in 1.0.6 (19 Jan 1998)
11781217
386 asm code replacing longest_match().
11791218
contrib/iostream/ by Kevin Ruland <[email protected]>
11801219
A C++ I/O streams interface to the zlib gz* functions
1181-
contrib/iostream2/ by Tyge L�vset <[email protected]>
1220+
contrib/iostream2/ by Tyge Løvset <[email protected]>
11821221
Another C++ I/O streams interface
11831222
contrib/untgz/ by "Pedro A. Aranda Guti\irrez" <[email protected]>
11841223
A very simple tar.gz file extractor using zlib
@@ -1267,7 +1306,7 @@ Changes in 1.0.1 (20 May 96) [1.0 skipped to avoid confusion]
12671306
- fix array overlay in deflate.c which sometimes caused bad compressed data
12681307
- fix inflate bug with empty stored block
12691308
- fix MSDOS medium model which was broken in 0.99
1270-
- fix deflateParams() which could generated bad compressed data.
1309+
- fix deflateParams() which could generate bad compressed data.
12711310
- Bytef is define'd instead of typedef'ed (work around Borland bug)
12721311
- added an INDEX file
12731312
- new makefiles for DJGPP (Makefile.dj2), 32-bit Borland (Makefile.b32),

etc/c/zlib/README

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

3-
zlib 1.2.8 is a general purpose data compression library. All the code is
3+
zlib 1.2.10 is a general purpose data compression library. All the code is
44
thread safe. The data format used by the zlib library is described by RFCs
55
(Request for Comments) 1950 to 1952 in the files
66
http://tools.ietf.org/html/rfc1950 (zlib format), rfc1951 (deflate format) and
@@ -31,7 +31,7 @@ Mark Nelson <[email protected]> wrote an article about zlib for the Jan. 1997
3131
issue of Dr. Dobb's Journal; a copy of the article is available at
3232
http://marknelson.us/1997/01/01/zlib-engine/ .
3333

34-
The changes made in version 1.2.8 are documented in the file ChangeLog.
34+
The changes made in version 1.2.10 are documented in the file ChangeLog.
3535

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

@@ -84,7 +84,7 @@ Acknowledgments:
8484

8585
Copyright notice:
8686

87-
(C) 1995-2013 Jean-loup Gailly and Mark Adler
87+
(C) 1995-2017 Jean-loup Gailly and Mark Adler
8888

8989
This software is provided 'as-is', without any express or implied
9090
warranty. In no event will the authors be held liable for any damages

etc/c/zlib/adler32.c

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
11
/* adler32.c -- compute the Adler-32 checksum of a data stream
2-
* Copyright (C) 1995-2011 Mark Adler
2+
* Copyright (C) 1995-2011, 2016 Mark Adler
33
* For conditions of distribution and use, see copyright notice in zlib.h
44
*/
55

66
/* @(#) $Id$ */
77

88
#include "zutil.h"
99

10-
#define local static
11-
1210
local uLong adler32_combine_ OF((uLong adler1, uLong adler2, z_off64_t len2));
1311

14-
#define BASE 65521 /* largest prime smaller than 65536 */
12+
#define BASE 65521U /* largest prime smaller than 65536 */
1513
#define NMAX 5552
1614
/* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */
1715

@@ -62,10 +60,10 @@ local uLong adler32_combine_ OF((uLong adler1, uLong adler2, z_off64_t len2));
6260
#endif
6361

6462
/* ========================================================================= */
65-
uLong ZEXPORT adler32(adler, buf, len)
63+
uLong ZEXPORT adler32_z(adler, buf, len)
6664
uLong adler;
6765
const Bytef *buf;
68-
uInt len;
66+
z_size_t len;
6967
{
7068
unsigned long sum2;
7169
unsigned n;
@@ -132,6 +130,15 @@ uLong ZEXPORT adler32(adler, buf, len)
132130
return adler | (sum2 << 16);
133131
}
134132

133+
/* ========================================================================= */
134+
uLong ZEXPORT adler32(adler, buf, len)
135+
uLong adler;
136+
const Bytef *buf;
137+
uInt len;
138+
{
139+
return adler32_z(adler, buf, len);
140+
}
141+
135142
/* ========================================================================= */
136143
local uLong adler32_combine_(adler1, adler2, len2)
137144
uLong adler1;
@@ -156,7 +163,7 @@ local uLong adler32_combine_(adler1, adler2, len2)
156163
sum2 += ((adler1 >> 16) & 0xffff) + ((adler2 >> 16) & 0xffff) + BASE - rem;
157164
if (sum1 >= BASE) sum1 -= BASE;
158165
if (sum1 >= BASE) sum1 -= BASE;
159-
if (sum2 >= (BASE << 1)) sum2 -= (BASE << 1);
166+
if (sum2 >= ((unsigned long)BASE << 1)) sum2 -= ((unsigned long)BASE << 1);
160167
if (sum2 >= BASE) sum2 -= BASE;
161168
return sum1 | (sum2 << 16);
162169
}

etc/c/zlib/compress.c

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* compress.c -- compress a memory buffer
2-
* Copyright (C) 1995-2005 Jean-loup Gailly.
2+
* Copyright (C) 1995-2005, 2014, 2016 Jean-loup Gailly, Mark Adler
33
* For conditions of distribution and use, see copyright notice in zlib.h
44
*/
55

@@ -28,16 +28,11 @@ int ZEXPORT compress2 (dest, destLen, source, sourceLen, level)
2828
{
2929
z_stream stream;
3030
int err;
31+
const uInt max = (uInt)-1;
32+
uLong left;
3133

32-
stream.next_in = (z_const Bytef *)source;
33-
stream.avail_in = (uInt)sourceLen;
34-
#ifdef MAXSEG_64K
35-
/* Check for source > 64K on 16-bit machine: */
36-
if ((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR;
37-
#endif
38-
stream.next_out = dest;
39-
stream.avail_out = (uInt)*destLen;
40-
if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR;
34+
left = *destLen;
35+
*destLen = 0;
4136

4237
stream.zalloc = (alloc_func)0;
4338
stream.zfree = (free_func)0;
@@ -46,15 +41,26 @@ int ZEXPORT compress2 (dest, destLen, source, sourceLen, level)
4641
err = deflateInit(&stream, level);
4742
if (err != Z_OK) return err;
4843

49-
err = deflate(&stream, Z_FINISH);
50-
if (err != Z_STREAM_END) {
51-
deflateEnd(&stream);
52-
return err == Z_OK ? Z_BUF_ERROR : err;
53-
}
54-
*destLen = stream.total_out;
44+
stream.next_out = dest;
45+
stream.avail_out = 0;
46+
stream.next_in = (z_const Bytef *)source;
47+
stream.avail_in = 0;
48+
49+
do {
50+
if (stream.avail_out == 0) {
51+
stream.avail_out = left > (uLong)max ? max : (uInt)left;
52+
left -= stream.avail_out;
53+
}
54+
if (stream.avail_in == 0) {
55+
stream.avail_in = sourceLen > (uLong)max ? max : (uInt)sourceLen;
56+
sourceLen -= stream.avail_in;
57+
}
58+
err = deflate(&stream, sourceLen ? Z_NO_FLUSH : Z_FINISH);
59+
} while (err == Z_OK);
5560

56-
err = deflateEnd(&stream);
57-
return err;
61+
*destLen = stream.total_out;
62+
deflateEnd(&stream);
63+
return err == Z_STREAM_END ? Z_OK : err;
5864
}
5965

6066
/* ===========================================================================

etc/c/zlib/crc32.c

Lines changed: 29 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* crc32.c -- compute the CRC-32 of a data stream
2-
* Copyright (C) 1995-2006, 2010, 2011, 2012 Mark Adler
2+
* Copyright (C) 1995-2006, 2010, 2011, 2012, 2016 Mark Adler
33
* For conditions of distribution and use, see copyright notice in zlib.h
44
*
55
* Thanks to Rodney Brown <[email protected]> for his contribution of faster
@@ -30,17 +30,15 @@
3030

3131
#include "zutil.h" /* for STDC and FAR definitions */
3232

33-
#define local static
34-
3533
/* Definitions for doing the crc four data bytes at a time. */
3634
#if !defined(NOBYFOUR) && defined(Z_U4)
3735
# define BYFOUR
3836
#endif
3937
#ifdef BYFOUR
4038
local unsigned long crc32_little OF((unsigned long,
41-
const unsigned char FAR *, unsigned));
39+
const unsigned char FAR *, z_size_t));
4240
local unsigned long crc32_big OF((unsigned long,
43-
const unsigned char FAR *, unsigned));
41+
const unsigned char FAR *, z_size_t));
4442
# define TBLS 8
4543
#else
4644
# define TBLS 1
@@ -201,10 +199,10 @@ const z_crc_t FAR * ZEXPORT get_crc_table()
201199
#define DO8 DO1; DO1; DO1; DO1; DO1; DO1; DO1; DO1
202200

203201
/* ========================================================================= */
204-
unsigned long ZEXPORT crc32(crc, buf, len)
202+
unsigned long ZEXPORT crc32_z(crc, buf, len)
205203
unsigned long crc;
206204
const unsigned char FAR *buf;
207-
uInt len;
205+
z_size_t len;
208206
{
209207
if (buf == Z_NULL) return 0UL;
210208

@@ -235,8 +233,29 @@ unsigned long ZEXPORT crc32(crc, buf, len)
235233
return crc ^ 0xffffffffUL;
236234
}
237235

236+
/* ========================================================================= */
237+
unsigned long ZEXPORT crc32(crc, buf, len)
238+
unsigned long crc;
239+
const unsigned char FAR *buf;
240+
uInt len;
241+
{
242+
return crc32_z(crc, buf, len);
243+
}
244+
238245
#ifdef BYFOUR
239246

247+
/*
248+
This BYFOUR code accesses the passed unsigned char * buffer with a 32-bit
249+
integer pointer type. This violates the strict aliasing rule, where a
250+
compiler can assume, for optimization purposes, that two pointers to
251+
fundamentally different types won't ever point to the same memory. This can
252+
manifest as a problem only if one of the pointers is written to. This code
253+
only reads from those pointers. So long as this code remains isolated in
254+
this compilation unit, there won't be a problem. For this reason, this code
255+
should not be copied and pasted into a compilation unit in which other code
256+
writes to the buffer that is passed to these routines.
257+
*/
258+
240259
/* ========================================================================= */
241260
#define DOLIT4 c ^= *buf4++; \
242261
c = crc_table[3][c & 0xff] ^ crc_table[2][(c >> 8) & 0xff] ^ \
@@ -247,7 +266,7 @@ unsigned long ZEXPORT crc32(crc, buf, len)
247266
local unsigned long crc32_little(crc, buf, len)
248267
unsigned long crc;
249268
const unsigned char FAR *buf;
250-
unsigned len;
269+
z_size_t len;
251270
{
252271
register z_crc_t c;
253272
register const z_crc_t FAR *buf4;
@@ -278,7 +297,7 @@ local unsigned long crc32_little(crc, buf, len)
278297
}
279298

280299
/* ========================================================================= */
281-
#define DOBIG4 c ^= *++buf4; \
300+
#define DOBIG4 c ^= *buf4++; \
282301
c = crc_table[4][c & 0xff] ^ crc_table[5][(c >> 8) & 0xff] ^ \
283302
crc_table[6][(c >> 16) & 0xff] ^ crc_table[7][c >> 24]
284303
#define DOBIG32 DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4
@@ -287,7 +306,7 @@ local unsigned long crc32_little(crc, buf, len)
287306
local unsigned long crc32_big(crc, buf, len)
288307
unsigned long crc;
289308
const unsigned char FAR *buf;
290-
unsigned len;
309+
z_size_t len;
291310
{
292311
register z_crc_t c;
293312
register const z_crc_t FAR *buf4;
@@ -300,7 +319,6 @@ local unsigned long crc32_big(crc, buf, len)
300319
}
301320

302321
buf4 = (const z_crc_t FAR *)(const void FAR *)buf;
303-
buf4--;
304322
while (len >= 32) {
305323
DOBIG32;
306324
len -= 32;
@@ -309,7 +327,6 @@ local unsigned long crc32_big(crc, buf, len)
309327
DOBIG4;
310328
len -= 4;
311329
}
312-
buf4++;
313330
buf = (const unsigned char FAR *)buf4;
314331

315332
if (len) do {

0 commit comments

Comments
 (0)