summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/libz/adler32.c3
-rw-r--r--lib/libz/compress.c3
-rw-r--r--lib/libz/crc32.c79
-rw-r--r--lib/libz/deflate.c9
-rw-r--r--lib/libz/deflate.h3
-rw-r--r--lib/libz/example.c3
-rw-r--r--lib/libz/infback.c4
-rw-r--r--lib/libz/inffast.c7
-rw-r--r--lib/libz/inflate.c8
-rw-r--r--lib/libz/inftrees.c20
-rw-r--r--lib/libz/trees.c7
-rw-r--r--lib/libz/uncompr.c3
-rw-r--r--lib/libz/zlib.38
-rw-r--r--lib/libz/zutil.c3
-rw-r--r--lib/libz/zutil.h9
15 files changed, 91 insertions, 78 deletions
diff --git a/lib/libz/adler32.c b/lib/libz/adler32.c
index 1bf48cf..624a169 100644
--- a/lib/libz/adler32.c
+++ b/lib/libz/adler32.c
@@ -3,8 +3,7 @@
* For conditions of distribution and use, see copyright notice in zlib.h
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+/* @(#) $Id$ */
#define ZLIB_INTERNAL
#include "zlib.h"
diff --git a/lib/libz/compress.c b/lib/libz/compress.c
index 7b349f5..24ef029 100644
--- a/lib/libz/compress.c
+++ b/lib/libz/compress.c
@@ -3,8 +3,7 @@
* For conditions of distribution and use, see copyright notice in zlib.h
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+/* @(#) $Id$ */
#define ZLIB_INTERNAL
#include "zlib.h"
diff --git a/lib/libz/crc32.c b/lib/libz/crc32.c
index efb152ac..b39c7e1 100644
--- a/lib/libz/crc32.c
+++ b/lib/libz/crc32.c
@@ -9,8 +9,15 @@
* of two increase in speed on a Power PC G4 (PPC7455) using gcc -O3.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+/* @(#) $Id$ */
+
+/*
+ Note on the use of DYNAMIC_CRC_TABLE: there is no mutex or semaphore
+ protection on the static variables used to control the first-use generation
+ of the crc tables. Therefore, if you #define DYNAMIC_CRC_TABLE, you should
+ first call get_crc_table() to initialize the tables before allowing more than
+ one thread to use crc32().
+ */
#ifdef MAKECRCH
# include <stdio.h>
@@ -59,7 +66,7 @@ __FBSDID("$FreeBSD$");
#ifdef DYNAMIC_CRC_TABLE
-local int crc_table_empty = 1;
+local volatile int crc_table_empty = 1;
local unsigned long FAR crc_table[TBLS][256];
local void make_crc_table OF((void));
#ifdef MAKECRCH
@@ -96,38 +103,51 @@ local void make_crc_table()
{
unsigned long c;
int n, k;
- unsigned long poly; /* polynomial exclusive-or pattern */
+ unsigned long poly; /* polynomial exclusive-or pattern */
/* terms of polynomial defining this crc (except x^32): */
+ static volatile int first = 1; /* flag to limit concurrent making */
static const unsigned char p[] = {0,1,2,4,5,7,8,10,11,12,16,22,23,26};
- /* make exclusive-or pattern from polynomial (0xedb88320UL) */
- poly = 0UL;
- for (n = 0; n < sizeof(p)/sizeof(unsigned char); n++)
- poly |= 1UL << (31 - p[n]);
-
- /* generate a crc for every 8-bit value */
- for (n = 0; n < 256; n++) {
- c = (unsigned long)n;
- for (k = 0; k < 8; k++)
- c = c & 1 ? poly ^ (c >> 1) : c >> 1;
- crc_table[0][n] = c;
- }
+ /* See if another task is already doing this (not thread-safe, but better
+ than nothing -- significantly reduces duration of vulnerability in
+ case the advice about DYNAMIC_CRC_TABLE is ignored) */
+ if (first) {
+ first = 0;
+
+ /* make exclusive-or pattern from polynomial (0xedb88320UL) */
+ poly = 0UL;
+ for (n = 0; n < sizeof(p)/sizeof(unsigned char); n++)
+ poly |= 1UL << (31 - p[n]);
+
+ /* generate a crc for every 8-bit value */
+ for (n = 0; n < 256; n++) {
+ c = (unsigned long)n;
+ for (k = 0; k < 8; k++)
+ c = c & 1 ? poly ^ (c >> 1) : c >> 1;
+ crc_table[0][n] = c;
+ }
#ifdef BYFOUR
- /* generate crc for each value followed by one, two, and three zeros, and
- then the byte reversal of those as well as the first table */
- for (n = 0; n < 256; n++) {
- c = crc_table[0][n];
- crc_table[4][n] = REV(c);
- for (k = 1; k < 4; k++) {
- c = crc_table[0][c & 0xff] ^ (c >> 8);
- crc_table[k][n] = c;
- crc_table[k + 4][n] = REV(c);
+ /* generate crc for each value followed by one, two, and three zeros,
+ and then the byte reversal of those as well as the first table */
+ for (n = 0; n < 256; n++) {
+ c = crc_table[0][n];
+ crc_table[4][n] = REV(c);
+ for (k = 1; k < 4; k++) {
+ c = crc_table[0][c & 0xff] ^ (c >> 8);
+ crc_table[k][n] = c;
+ crc_table[k + 4][n] = REV(c);
+ }
}
- }
#endif /* BYFOUR */
- crc_table_empty = 0;
+ crc_table_empty = 0;
+ }
+ else { /* not first */
+ /* wait for the other guy to finish (not efficient, but rare) */
+ while (crc_table_empty)
+ ;
+ }
#ifdef MAKECRCH
/* write out CRC tables to crc32.h */
@@ -181,9 +201,10 @@ local void write_table(out, table)
const unsigned long FAR * ZEXPORT get_crc_table()
{
#ifdef DYNAMIC_CRC_TABLE
- if (crc_table_empty) make_crc_table();
+ if (crc_table_empty)
+ make_crc_table();
#endif /* DYNAMIC_CRC_TABLE */
- return (const unsigned long FAR *)crc_table;
+ return (const unsigned long FAR *)crc_table;
}
/* ========================================================================= */
diff --git a/lib/libz/deflate.c b/lib/libz/deflate.c
index 155b72a..0fc53bc 100644
--- a/lib/libz/deflate.c
+++ b/lib/libz/deflate.c
@@ -1,11 +1,8 @@
/* deflate.c -- compress data using the deflation algorithm
- * Copyright (C) 1995-2003 Jean-loup Gailly.
+ * Copyright (C) 1995-2004 Jean-loup Gailly.
* For conditions of distribution and use, see copyright notice in zlib.h
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
/*
* ALGORITHM
*
@@ -50,12 +47,12 @@ __FBSDID("$FreeBSD$");
*
*/
-/* @(#) $FreeBSD$ */
+/* @(#) $Id$ */
#include "deflate.h"
const char deflate_copyright[] =
- " deflate 1.2.1 Copyright 1995-2003 Jean-loup Gailly ";
+ " deflate 1.2.2 Copyright 1995-2004 Jean-loup Gailly ";
/*
If you use the zlib library in a product, an acknowledgment is welcome
in the documentation of your product. If for some reason you cannot
diff --git a/lib/libz/deflate.h b/lib/libz/deflate.h
index 8f4ff2d..410681d 100644
--- a/lib/libz/deflate.h
+++ b/lib/libz/deflate.h
@@ -8,7 +8,7 @@
subject to change. Applications should only use zlib.h.
*/
-/* @(#) $FreeBSD$ */
+/* @(#) $Id$ */
#ifndef DEFLATE_H
#define DEFLATE_H
@@ -95,7 +95,6 @@ typedef struct internal_state {
Bytef *pending_out; /* next pending byte to output to the stream */
int pending; /* nb of bytes in the pending buffer */
int wrap; /* bit 0 true for zlib, bit 1 true for gzip */
- Byte data_type; /* UNKNOWN, BINARY or ASCII */
Byte method; /* STORED (for zip only) or DEFLATED */
int last_flush; /* value of flush param for previous deflate call */
diff --git a/lib/libz/example.c b/lib/libz/example.c
index c528b62..c2361f9 100644
--- a/lib/libz/example.c
+++ b/lib/libz/example.c
@@ -3,8 +3,7 @@
* For conditions of distribution and use, see copyright notice in zlib.h
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+/* @(#) $Id$ */
#include <stdio.h>
#include "zlib.h"
diff --git a/lib/libz/infback.c b/lib/libz/infback.c
index e970998..262f97c7 100644
--- a/lib/libz/infback.c
+++ b/lib/libz/infback.c
@@ -434,8 +434,8 @@ void FAR *out_desc;
}
}
- if (state->mode == BAD)
- break;
+ /* handle error breaks in while */
+ if (state->mode == BAD) break;
/* build code tables */
state->next = state->codes;
diff --git a/lib/libz/inffast.c b/lib/libz/inffast.c
index c5c93a5..8c02a17 100644
--- a/lib/libz/inffast.c
+++ b/lib/libz/inffast.c
@@ -1,11 +1,8 @@
/* inffast.c -- fast decoding
- * Copyright (C) 1995-2003 Mark Adler
+ * Copyright (C) 1995-2004 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include "zutil.h"
#include "inftrees.h"
#include "inflate.h"
@@ -22,7 +19,7 @@ __FBSDID("$FreeBSD$");
- none
No measurable difference:
- Pentium III (Anderson)
- - 68060 (Nikl)
+ - M68060 (Nikl)
*/
#ifdef POSTINC
# define OFF 0
diff --git a/lib/libz/inflate.c b/lib/libz/inflate.c
index 913f002..c6d3826 100644
--- a/lib/libz/inflate.c
+++ b/lib/libz/inflate.c
@@ -80,9 +80,6 @@
* The history for versions after 1.2.0 are in ChangeLog in zlib distribution.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include "zutil.h"
#include "inftrees.h"
#include "inflate.h"
@@ -112,6 +109,7 @@ z_streamp strm;
state = (struct inflate_state FAR *)strm->state;
strm->total_in = strm->total_out = state->total = 0;
strm->msg = Z_NULL;
+ strm->adler = 1; /* to support ill-conceived Java test suite */
state->mode = HEAD;
state->last = 0;
state->havedict = 0;
@@ -864,8 +862,8 @@ int flush;
}
}
- if (state->mode == BAD)
- break;
+ /* handle error breaks in while */
+ if (state->mode == BAD) break;
/* build code tables */
state->next = state->codes;
diff --git a/lib/libz/inftrees.c b/lib/libz/inftrees.c
index 4d0b487..8a896b2 100644
--- a/lib/libz/inftrees.c
+++ b/lib/libz/inftrees.c
@@ -1,18 +1,15 @@
/* inftrees.c -- generate Huffman trees for efficient decoding
- * Copyright (C) 1995-2003 Mark Adler
+ * Copyright (C) 1995-2004 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include "zutil.h"
#include "inftrees.h"
#define MAXBITS 15
const char inflate_copyright[] =
- " inflate 1.2.1 Copyright 1995-2003 Mark Adler ";
+ " inflate 1.2.2 Copyright 1995-2004 Mark Adler ";
/*
If you use the zlib library in a product, an acknowledgment is welcome
in the documentation of your product. If for some reason you cannot
@@ -65,7 +62,7 @@ unsigned short FAR *work;
35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0};
static const unsigned short lext[31] = { /* Length codes 257..285 extra */
16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18,
- 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 76, 66};
+ 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 199, 198};
static const unsigned short dbase[32] = { /* Distance codes 0..29 base */
1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,
257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,
@@ -117,7 +114,15 @@ unsigned short FAR *work;
for (max = MAXBITS; max >= 1; max--)
if (count[max] != 0) break;
if (root > max) root = max;
- if (max == 0) return -1; /* no codes! */
+ if (max == 0) { /* no symbols to code at all */
+ this.op = (unsigned char)64; /* invalid code marker */
+ this.bits = (unsigned char)1;
+ this.val = (unsigned short)0;
+ *(*table)++ = this; /* make a table to force an error */
+ *(*table)++ = this;
+ *bits = 1;
+ return 0; /* no symbols, but wait for decoding to report error */
+ }
for (min = 1; min <= MAXBITS; min++)
if (count[min] != 0) break;
if (root < min) root = min;
@@ -298,7 +303,6 @@ unsigned short FAR *work;
drop = 0;
len = root;
next = *table;
- curr = root;
this.bits = (unsigned char)len;
}
diff --git a/lib/libz/trees.c b/lib/libz/trees.c
index 3f8289f..52c820f 100644
--- a/lib/libz/trees.c
+++ b/lib/libz/trees.c
@@ -29,8 +29,7 @@
* Addison-Wesley, 1983. ISBN 0-201-06672-6.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+/* @(#) $Id$ */
/* #define GEN_TREES_H */
@@ -932,7 +931,7 @@ void _tr_flush_block(s, buf, stored_len, eof)
if (s->level > 0) {
/* Check if the file is ascii or binary */
- if (s->data_type == Z_UNKNOWN) set_data_type(s);
+ if (s->strm->data_type == Z_UNKNOWN) set_data_type(s);
/* Construct the literal and distance trees */
build_tree(s, (tree_desc *)(&(s->l_desc)));
@@ -1132,7 +1131,7 @@ local void set_data_type(s)
while (n < 7) bin_freq += s->dyn_ltree[n++].Freq;
while (n < 128) ascii_freq += s->dyn_ltree[n++].Freq;
while (n < LITERALS) bin_freq += s->dyn_ltree[n++].Freq;
- s->data_type = (Byte)(bin_freq > (ascii_freq >> 2) ? Z_BINARY : Z_ASCII);
+ s->strm->data_type = bin_freq > (ascii_freq >> 2) ? Z_BINARY : Z_ASCII;
}
/* ===========================================================================
diff --git a/lib/libz/uncompr.c b/lib/libz/uncompr.c
index a428b5a..b59e3d0 100644
--- a/lib/libz/uncompr.c
+++ b/lib/libz/uncompr.c
@@ -3,8 +3,7 @@
* For conditions of distribution and use, see copyright notice in zlib.h
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+/* @(#) $Id$ */
#define ZLIB_INTERNAL
#include "zlib.h"
diff --git a/lib/libz/zlib.3 b/lib/libz/zlib.3
index a1e0196..3139e24 100644
--- a/lib/libz/zlib.3
+++ b/lib/libz/zlib.3
@@ -1,6 +1,4 @@
-.\" $FreeBSD$
-.\"
-.TH ZLIB 3 "17 November 2003"
+.TH ZLIB 3 "3 October 2004"
.SH NAME
zlib \- compression/decompression library
.SH SYNOPSIS
@@ -135,8 +133,8 @@ before asking for help.
Send questions and/or comments to zlib@gzip.org,
or (for the Windows DLL version) to Gilles Vollant (info@winimage.com).
.SH AUTHORS
-Version 1.2.1
-Copyright (C) 1995-2003 Jean-loup Gailly (jloup@gzip.org)
+Version 1.2.2
+Copyright (C) 1995-2004 Jean-loup Gailly (jloup@gzip.org)
and Mark Adler (madler@alumni.caltech.edu).
.LP
This software is provided "as-is,"
diff --git a/lib/libz/zutil.c b/lib/libz/zutil.c
index 8f749ce..0ef4f99 100644
--- a/lib/libz/zutil.c
+++ b/lib/libz/zutil.c
@@ -3,8 +3,7 @@
* For conditions of distribution and use, see copyright notice in zlib.h
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+/* @(#) $Id$ */
#include "zutil.h"
diff --git a/lib/libz/zutil.h b/lib/libz/zutil.h
index 60e5d2b..7b42edca 100644
--- a/lib/libz/zutil.h
+++ b/lib/libz/zutil.h
@@ -8,7 +8,7 @@
subject to change. Applications should only use zlib.h.
*/
-/* @(#) $FreeBSD$ */
+/* @(#) $Id$ */
#ifndef ZUTIL_H
#define ZUTIL_H
@@ -189,9 +189,14 @@ extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
# define NO_vsnprintf
# endif
#endif
+#ifdef VMS
+# define NO_vsnprintf
+#endif
#ifdef HAVE_STRERROR
- extern char *strerror OF((int));
+# ifndef VMS
+ extern char *strerror OF((int));
+# endif
# define zstrerror(errnum) strerror(errnum)
#else
# define zstrerror(errnum) ""
OpenPOWER on IntegriCloud