diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 2003-12-17 00:28:20 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 2003-12-17 00:28:20 +0000 |
commit | 020328685b9a93cb12e3cccaf36216ab48d8f8b5 (patch) | |
tree | 71d19b20f073282211a5b557c1fb01546f104270 /lib | |
parent | a833eb464324ac2a5c5087f0aa052ff1551f9241 (diff) |
sync with sys/lib/libz; adds #ifdef SMALL and one more #ifndef SLOW
henning@ OK
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libz/infback.c | 14 | ||||
-rw-r--r-- | lib/libz/inffast.c | 14 | ||||
-rw-r--r-- | lib/libz/inflate.c | 78 |
3 files changed, 104 insertions, 2 deletions
diff --git a/lib/libz/infback.c b/lib/libz/infback.c index 110b03b857f..9496e675c7e 100644 --- a/lib/libz/infback.c +++ b/lib/libz/infback.c @@ -307,7 +307,11 @@ void FAR *out_desc; state->mode = TABLE; break; case 3: +#ifdef SMALL + strm->msg = "error"; +#else strm->msg = (char *)"invalid block type"; +#endif state->mode = BAD; } DROPBITS(2); @@ -318,7 +322,11 @@ void FAR *out_desc; BYTEBITS(); /* go to byte boundary */ NEEDBITS(32); if ((hold & 0xffff) != ((hold >> 16) ^ 0xffff)) { +#ifdef SMALL + strm->msg = "error"; +#else strm->msg = (char *)"invalid stored block lengths"; +#endif state->mode = BAD; break; } @@ -356,7 +364,11 @@ void FAR *out_desc; DROPBITS(4); #ifndef PKZIP_BUG_WORKAROUND if (state->nlen > 286 || state->ndist > 30) { +#ifdef SMALL + strm->msg = "error"; +#else strm->msg = (char *)"too many length or distance symbols"; +#endif state->mode = BAD; break; } @@ -458,6 +470,7 @@ void FAR *out_desc; state->mode = LEN; case LEN: +#ifndef SLOW /* use inflate_fast() if we have enough input and output */ if (have >= 6 && left >= 258) { RESTORE(); @@ -467,6 +480,7 @@ void FAR *out_desc; LOAD(); break; } +#endif /* get a literal, length, or end-of-block code */ for (;;) { diff --git a/lib/libz/inffast.c b/lib/libz/inffast.c index 137d8b14d3b..33b9feb54b7 100644 --- a/lib/libz/inffast.c +++ b/lib/libz/inffast.c @@ -1,4 +1,4 @@ -/* $OpenBSD: inffast.c,v 1.4 2003/12/16 22:33:02 henning Exp $ */ +/* $OpenBSD: inffast.c,v 1.5 2003/12/17 00:28:19 millert Exp $ */ /* inffast.c -- fast decoding * Copyright (C) 1995-2003 Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h @@ -175,7 +175,11 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */ if (dist > op) { /* see if copy from window */ op = dist - op; /* distance back in window */ if (op > whave) { +#ifdef SMALL + strm->msg = "error"; +#else strm->msg = (char *)"invalid distance too far back"; +#endif state->mode = BAD; break; } @@ -251,7 +255,11 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */ goto dodist; } else { +#ifdef SMALL + strm->msg = "error"; +#else strm->msg = (char *)"invalid distance code"; +#endif state->mode = BAD; break; } @@ -266,7 +274,11 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */ break; } else { +#ifdef SMALL + strm->msg = "error"; +#else strm->msg = (char *)"invalid literal/length code"; +#endif state->mode = BAD; break; } diff --git a/lib/libz/inflate.c b/lib/libz/inflate.c index adf7f2d6f91..27f87a69c95 100644 --- a/lib/libz/inflate.c +++ b/lib/libz/inflate.c @@ -1,4 +1,4 @@ -/* $OpenBSD: inflate.c,v 1.5 2003/12/17 00:24:47 henning Exp $ */ +/* $OpenBSD: inflate.c,v 1.6 2003/12/17 00:28:19 millert Exp $ */ /* inflate.c -- zlib decompression * Copyright (C) 1995-2003 Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h @@ -587,18 +587,30 @@ int flush; if ( #endif ((BITS(8) << 8) + (hold >> 8)) % 31) { +#ifdef SMALL + strm->msg = "error"; +#else strm->msg = (char *)"incorrect header check"; +#endif state->mode = BAD; break; } if (BITS(4) != Z_DEFLATED) { +#ifdef SMALL + strm->msg = "error"; +#else strm->msg = (char *)"unknown compression method"; +#endif state->mode = BAD; break; } DROPBITS(4); if (BITS(4) + 8 > state->wbits) { +#ifdef SMALL + strm->msg = "error"; +#else strm->msg = (char *)"invalid window size"; +#endif state->mode = BAD; break; } @@ -612,12 +624,20 @@ int flush; NEEDBITS(16); state->flags = (int)(hold); if ((state->flags & 0xff) != Z_DEFLATED) { +#ifdef SMALL + strm->msg = "error"; +#else strm->msg = (char *)"unknown compression method"; +#endif state->mode = BAD; break; } if (state->flags & 0xe000) { +#ifdef SMALL + strm->msg = "error"; +#else strm->msg = (char *)"unknown header flags set"; +#endif state->mode = BAD; break; } @@ -688,7 +708,11 @@ int flush; if (state->flags & 0x0200) { NEEDBITS(16); if (hold != (state->check & 0xffff)) { +#ifdef SMALL + strm->msg = "error"; +#else strm->msg = (char *)"header crc mismatch"; +#endif state->mode = BAD; break; } @@ -739,7 +763,11 @@ int flush; state->mode = TABLE; break; case 3: +#ifdef SMALL + strm->msg = "error"; +#else strm->msg = (char *)"invalid block type"; +#endif state->mode = BAD; } DROPBITS(2); @@ -748,7 +776,11 @@ int flush; BYTEBITS(); /* go to byte boundary */ NEEDBITS(32); if ((hold & 0xffff) != ((hold >> 16) ^ 0xffff)) { +#ifdef SMALL + strm->msg = "error"; +#else strm->msg = (char *)"invalid stored block lengths"; +#endif state->mode = BAD; break; } @@ -784,7 +816,11 @@ int flush; DROPBITS(4); #ifndef PKZIP_BUG_WORKAROUND if (state->nlen > 286 || state->ndist > 30) { +#ifdef SMALL + strm->msg = "error"; +#else strm->msg = (char *)"too many length or distance symbols"; +#endif state->mode = BAD; break; } @@ -806,7 +842,11 @@ int flush; ret = inflate_table(CODES, state->lens, 19, &(state->next), &(state->lenbits), state->work); if (ret) { +#ifdef SMALL + strm->msg = "error"; +#else strm->msg = (char *)"invalid code lengths set"; +#endif state->mode = BAD; break; } @@ -830,7 +870,11 @@ int flush; NEEDBITS(this.bits + 2); DROPBITS(this.bits); if (state->have == 0) { +#ifdef SMALL + strm->msg = "error"; +#else strm->msg = (char *)"invalid bit length repeat"; +#endif state->mode = BAD; break; } @@ -853,7 +897,11 @@ int flush; DROPBITS(7); } if (state->have + copy > state->nlen + state->ndist) { +#ifdef SMALL + strm->msg = "error"; +#else strm->msg = (char *)"invalid bit length repeat"; +#endif state->mode = BAD; break; } @@ -869,7 +917,11 @@ int flush; ret = inflate_table(LENS, state->lens, state->nlen, &(state->next), &(state->lenbits), state->work); if (ret) { +#ifdef SMALL + strm->msg = "error"; +#else strm->msg = (char *)"invalid literal/lengths set"; +#endif state->mode = BAD; break; } @@ -878,7 +930,11 @@ int flush; ret = inflate_table(DISTS, state->lens + state->nlen, state->ndist, &(state->next), &(state->distbits), state->work); if (ret) { +#ifdef SMALL + strm->msg = "error"; +#else strm->msg = (char *)"invalid distances set"; +#endif state->mode = BAD; break; } @@ -923,7 +979,11 @@ int flush; break; } if (this.op & 64) { +#ifdef SMALL + strm->msg = "error"; +#else strm->msg = (char *)"invalid literal/length code"; +#endif state->mode = BAD; break; } @@ -955,7 +1015,11 @@ int flush; } DROPBITS(this.bits); if (this.op & 64) { +#ifdef SMALL + strm->msg = "error"; +#else strm->msg = (char *)"invalid distance code"; +#endif state->mode = BAD; break; } @@ -969,7 +1033,11 @@ int flush; DROPBITS(state->extra); } if (state->offset > state->whave + out - left) { +#ifdef SMALL + strm->msg = "error"; +#else strm->msg = (char *)"invalid distance too far back"; +#endif state->mode = BAD; break; } @@ -1021,7 +1089,11 @@ int flush; state->flags ? hold : #endif REVERSE(hold)) != state->check) { +#ifdef SMALL + strm->msg = "error"; +#else strm->msg = (char *)"incorrect data check"; +#endif state->mode = BAD; break; } @@ -1034,7 +1106,11 @@ int flush; if (state->wrap && state->flags) { NEEDBITS(32); if (hold != (state->total & 0xffffffffUL)) { +#ifdef SMALL + strm->msg = "error"; +#else strm->msg = (char *)"incorrect length check"; +#endif state->mode = BAD; break; } |