diff options
author | 2003-12-16 23:58:30 +0000 | |
---|---|---|
committer | 2003-12-16 23:58:30 +0000 | |
commit | 0ede0c43951ad252a092f48ce8877e3d400a5eb2 (patch) | |
tree | 8256d63a3e2edce4c2c375315773456ba2f1179a | |
parent | Update to zlib 1.2.1 (diff) | |
download | wireguard-openbsd-0ede0c43951ad252a092f48ce8877e3d400a5eb2.tar.xz wireguard-openbsd-0ede0c43951ad252a092f48ce8877e3d400a5eb2.zip |
Add #ifdef SMALL and #ifdef SLOW and include sys/unistd.h instead of unistd.h
-rw-r--r-- | sys/lib/libz/infback.c | 14 | ||||
-rw-r--r-- | sys/lib/libz/inffast.c | 14 | ||||
-rw-r--r-- | sys/lib/libz/inflate.c | 80 | ||||
-rw-r--r-- | sys/lib/libz/zconf.h | 6 |
4 files changed, 109 insertions, 5 deletions
diff --git a/sys/lib/libz/infback.c b/sys/lib/libz/infback.c index 110b03b857f..9496e675c7e 100644 --- a/sys/lib/libz/infback.c +++ b/sys/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/sys/lib/libz/inffast.c b/sys/lib/libz/inffast.c index ef0f4151dc7..982239effb4 100644 --- a/sys/lib/libz/inffast.c +++ b/sys/lib/libz/inffast.c @@ -1,4 +1,4 @@ -/* $OpenBSD: inffast.c,v 1.8 2003/12/16 23:57:48 millert Exp $ */ +/* $OpenBSD: inffast.c,v 1.9 2003/12/16 23:58:30 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/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; } diff --git a/sys/lib/libz/zconf.h b/sys/lib/libz/zconf.h index 576ce053ee4..49beebb1c8e 100644 --- a/sys/lib/libz/zconf.h +++ b/sys/lib/libz/zconf.h @@ -1,4 +1,4 @@ -/* $OpenBSD: zconf.h,v 1.7 2003/12/16 23:57:48 millert Exp $ */ +/* $OpenBSD: zconf.h,v 1.8 2003/12/16 23:58:30 millert Exp $ */ /* zconf.h -- configuration of the zlib compression library * Copyright (C) 1995-2003 Jean-loup Gailly. * For conditions of distribution and use, see copyright notice in zlib.h @@ -275,8 +275,8 @@ typedef uLong FAR uLongf; typedef Byte *voidp; #endif -#include <sys/types.h> /* for off_t */ -#include <unistd.h> /* for SEEK_* and off_t */ +#include <sys/types.h> /* for off_t */ +#include <sys/unistd.h> /* for SEEK_* and off_t */ #define z_off_t off_t #ifndef SEEK_SET # define SEEK_SET 0 /* Seek from beginning of file. */ |