summaryrefslogtreecommitdiffstats
path: root/compat/zlib/contrib/infback9/infback9.c
diff options
context:
space:
mode:
authornijtmans <nijtmans>2010-03-16 09:01:02 (GMT)
committernijtmans <nijtmans>2010-03-16 09:01:02 (GMT)
commitd8aa6f53b956aac50cc8abbee8efde417120f022 (patch)
treead38e8daca52c2a4a161ed744d7579720ced7cb8 /compat/zlib/contrib/infback9/infback9.c
parent6b64f45b9a293ab9cd7c97afa0399c6c37bd4a00 (diff)
downloadtcl-d8aa6f53b956aac50cc8abbee8efde417120f022.zip
tcl-d8aa6f53b956aac50cc8abbee8efde417120f022.tar.gz
tcl-d8aa6f53b956aac50cc8abbee8efde417120f022.tar.bz2
Upgrade zlib to version 1.2.4
Diffstat (limited to 'compat/zlib/contrib/infback9/infback9.c')
-rw-r--r--compat/zlib/contrib/infback9/infback9.c91
1 files changed, 50 insertions, 41 deletions
diff --git a/compat/zlib/contrib/infback9/infback9.c b/compat/zlib/contrib/infback9/infback9.c
index f5ddde6..7bbe90c 100644
--- a/compat/zlib/contrib/infback9/infback9.c
+++ b/compat/zlib/contrib/infback9/infback9.c
@@ -1,5 +1,5 @@
/* infback9.c -- inflate deflate64 data using a call-back interface
- * Copyright (C) 1995-2003 Mark Adler
+ * Copyright (C) 1995-2008 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
*/
@@ -242,7 +242,7 @@ void FAR *out_desc;
code const FAR *distcode; /* starting table for distance codes */
unsigned lenbits; /* index bits for lencode */
unsigned distbits; /* index bits for distcode */
- code this; /* current decoding table entry */
+ code here; /* current decoding table entry */
code last; /* parent table entry */
unsigned len; /* length to copy for repeats, bits to drop */
int ret; /* return code */
@@ -384,19 +384,19 @@ void FAR *out_desc;
state->have = 0;
while (state->have < state->nlen + state->ndist) {
for (;;) {
- this = lencode[BITS(lenbits)];
- if ((unsigned)(this.bits) <= bits) break;
+ here = lencode[BITS(lenbits)];
+ if ((unsigned)(here.bits) <= bits) break;
PULLBYTE();
}
- if (this.val < 16) {
- NEEDBITS(this.bits);
- DROPBITS(this.bits);
- state->lens[state->have++] = this.val;
+ if (here.val < 16) {
+ NEEDBITS(here.bits);
+ DROPBITS(here.bits);
+ state->lens[state->have++] = here.val;
}
else {
- if (this.val == 16) {
- NEEDBITS(this.bits + 2);
- DROPBITS(this.bits);
+ if (here.val == 16) {
+ NEEDBITS(here.bits + 2);
+ DROPBITS(here.bits);
if (state->have == 0) {
strm->msg = (char *)"invalid bit length repeat";
mode = BAD;
@@ -406,16 +406,16 @@ void FAR *out_desc;
copy = 3 + BITS(2);
DROPBITS(2);
}
- else if (this.val == 17) {
- NEEDBITS(this.bits + 3);
- DROPBITS(this.bits);
+ else if (here.val == 17) {
+ NEEDBITS(here.bits + 3);
+ DROPBITS(here.bits);
len = 0;
copy = 3 + BITS(3);
DROPBITS(3);
}
else {
- NEEDBITS(this.bits + 7);
- DROPBITS(this.bits);
+ NEEDBITS(here.bits + 7);
+ DROPBITS(here.bits);
len = 0;
copy = 11 + BITS(7);
DROPBITS(7);
@@ -433,7 +433,16 @@ void FAR *out_desc;
/* handle error breaks in while */
if (mode == BAD) break;
- /* build code tables */
+ /* check for end-of-block code (better have one) */
+ if (state->lens[256] == 0) {
+ strm->msg = (char *)"invalid code -- missing end-of-block";
+ mode = BAD;
+ break;
+ }
+
+ /* build code tables -- note: do not change the lenbits or distbits
+ values here (9 and 6) without reading the comments in inftree9.h
+ concerning the ENOUGH constants, which depend on those values */
state->next = state->codes;
lencode = (code const FAR *)(state->next);
lenbits = 9;
@@ -460,28 +469,28 @@ void FAR *out_desc;
case LEN:
/* get a literal, length, or end-of-block code */
for (;;) {
- this = lencode[BITS(lenbits)];
- if ((unsigned)(this.bits) <= bits) break;
+ here = lencode[BITS(lenbits)];
+ if ((unsigned)(here.bits) <= bits) break;
PULLBYTE();
}
- if (this.op && (this.op & 0xf0) == 0) {
- last = this;
+ if (here.op && (here.op & 0xf0) == 0) {
+ last = here;
for (;;) {
- this = lencode[last.val +
+ here = lencode[last.val +
(BITS(last.bits + last.op) >> last.bits)];
- if ((unsigned)(last.bits + this.bits) <= bits) break;
+ if ((unsigned)(last.bits + here.bits) <= bits) break;
PULLBYTE();
}
DROPBITS(last.bits);
}
- DROPBITS(this.bits);
- length = (unsigned)this.val;
+ DROPBITS(here.bits);
+ length = (unsigned)here.val;
/* process literal */
- if (this.op == 0) {
- Tracevv((stderr, this.val >= 0x20 && this.val < 0x7f ?
+ if (here.op == 0) {
+ Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ?
"inflate: literal '%c'\n" :
- "inflate: literal 0x%02x\n", this.val));
+ "inflate: literal 0x%02x\n", here.val));
ROOM();
*put++ = (unsigned char)(length);
left--;
@@ -490,21 +499,21 @@ void FAR *out_desc;
}
/* process end of block */
- if (this.op & 32) {
+ if (here.op & 32) {
Tracevv((stderr, "inflate: end of block\n"));
mode = TYPE;
break;
}
/* invalid code */
- if (this.op & 64) {
+ if (here.op & 64) {
strm->msg = (char *)"invalid literal/length code";
mode = BAD;
break;
}
/* length code -- get extra bits, if any */
- extra = (unsigned)(this.op) & 31;
+ extra = (unsigned)(here.op) & 31;
if (extra != 0) {
NEEDBITS(extra);
length += BITS(extra);
@@ -514,30 +523,30 @@ void FAR *out_desc;
/* get distance code */
for (;;) {
- this = distcode[BITS(distbits)];
- if ((unsigned)(this.bits) <= bits) break;
+ here = distcode[BITS(distbits)];
+ if ((unsigned)(here.bits) <= bits) break;
PULLBYTE();
}
- if ((this.op & 0xf0) == 0) {
- last = this;
+ if ((here.op & 0xf0) == 0) {
+ last = here;
for (;;) {
- this = distcode[last.val +
+ here = distcode[last.val +
(BITS(last.bits + last.op) >> last.bits)];
- if ((unsigned)(last.bits + this.bits) <= bits) break;
+ if ((unsigned)(last.bits + here.bits) <= bits) break;
PULLBYTE();
}
DROPBITS(last.bits);
}
- DROPBITS(this.bits);
- if (this.op & 64) {
+ DROPBITS(here.bits);
+ if (here.op & 64) {
strm->msg = (char *)"invalid distance code";
mode = BAD;
break;
}
- offset = (unsigned)this.val;
+ offset = (unsigned)here.val;
/* get distance extra bits, if any */
- extra = (unsigned)(this.op) & 15;
+ extra = (unsigned)(here.op) & 15;
if (extra != 0) {
NEEDBITS(extra);
offset += BITS(extra);