summaryrefslogtreecommitdiff
path: root/zlib/inffast.c
diff options
context:
space:
mode:
authorTom Tromey <tromey@redhat.com>2005-09-12 17:42:53 +0000
committerTom Tromey <tromey@gcc.gnu.org>2005-09-12 17:42:53 +0000
commitef3381664e516d137c80ebbf48c085220d5810ab (patch)
treeafad186af73219e6bb1a8cb8eac61485fb4eec97 /zlib/inffast.c
parent3ec980b182de950223663d4a3ef65177fa887501 (diff)
downloadgcc-ef3381664e516d137c80ebbf48c085220d5810ab.tar.gz
* Imported zlib 1.2.3; merged local changes.
From-SVN: r104184
Diffstat (limited to 'zlib/inffast.c')
-rw-r--r--zlib/inffast.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/zlib/inffast.c b/zlib/inffast.c
index c716440a92a..bbee92ed1e6 100644
--- a/zlib/inffast.c
+++ b/zlib/inffast.c
@@ -1,5 +1,5 @@
/* 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
*/
@@ -19,7 +19,7 @@
- none
No measurable difference:
- Pentium III (Anderson)
- - 68060 (Nikl)
+ - M68060 (Nikl)
*/
#ifdef POSTINC
# define OFF 0
@@ -74,6 +74,9 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */
unsigned char FAR *out; /* local strm->next_out */
unsigned char FAR *beg; /* inflate()'s initial strm->next_out */
unsigned char FAR *end; /* while out < end, enough space available */
+#ifdef INFLATE_STRICT
+ unsigned dmax; /* maximum distance from zlib header */
+#endif
unsigned wsize; /* window size or zero if not using window */
unsigned whave; /* valid bytes in the window */
unsigned write; /* window write index */
@@ -98,6 +101,9 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */
out = strm->next_out - OFF;
beg = out - (start - strm->avail_out);
end = out + (strm->avail_out - 257);
+#ifdef INFLATE_STRICT
+ dmax = state->dmax;
+#endif
wsize = state->wsize;
whave = state->whave;
write = state->write;
@@ -167,6 +173,13 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */
}
}
dist += (unsigned)hold & ((1U << op) - 1);
+#ifdef INFLATE_STRICT
+ if (dist > dmax) {
+ strm->msg = (char *)"invalid distance too far back";
+ state->mode = BAD;
+ break;
+ }
+#endif
hold >>= op;
bits -= op;
Tracevv((stderr, "inflate: distance %u\n", dist));