diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 2003-12-16 23:58:31 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 2003-12-16 23:58:31 +0000 |
commit | ea064523b82a76cc6a1a61843793695ab6227472 (patch) | |
tree | a0eea1b42577b3dc5a559a3d0f96302ed4bef21e /sys/lib/libz/inflate.c | |
parent | 119ff8aeb381bd2409167fb7eeaf9ea9e5b43fa9 (diff) |
Add #ifdef SMALL and #ifdef SLOW and include sys/unistd.h instead of unistd.h
Diffstat (limited to 'sys/lib/libz/inflate.c')
-rw-r--r-- | sys/lib/libz/inflate.c | 80 |
1 files changed, 79 insertions, 1 deletions
diff --git a/sys/lib/libz/inflate.c b/sys/lib/libz/inflate.c index 73884b69c74..61ed2726416 100644 --- a/sys/lib/libz/inflate.c +++ b/sys/lib/libz/inflate.c @@ -1,4 +1,4 @@ -/* $OpenBSD: inflate.c,v 1.8 2003/12/16 23:57:48 millert Exp $ */ +/* $OpenBSD: inflate.c,v 1.9 2003/12/16 23:58:30 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,19 +930,25 @@ 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; } Tracev((stderr, "inflate: codes ok\n")); state->mode = LEN; case LEN: +#ifndef SLOW if (have >= 6 && left >= 258) { RESTORE(); inflate_fast(strm, out); LOAD(); break; } +#endif for (;;) { this = state->lencode[BITS(state->lenbits)]; if ((unsigned)(this.bits) <= bits) break; @@ -921,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; } @@ -953,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; } @@ -967,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; } @@ -1019,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; } @@ -1032,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; } |