[hackers] [flate] fix deflate bug (match beyond endpos) || nsz

From: <hg_AT_suckless.org>
Date: Sun, 8 Aug 2010 14:47:37 +0000 (UTC)

changeset: 123:37670036b150
tag: tip
user: nsz_AT_tpx
date: Sun Aug 08 16:28:50 2010 +0200
files: deflate.c
description:
fix deflate bug (match beyond endpos)

diff -r ebb263e3b298 -r 37670036b150 deflate.c
--- a/deflate.c Mon Aug 24 10:47:09 2009 +0200
+++ b/deflate.c Sun Aug 08 16:28:50 2010 +0200
@@ -327,7 +327,7 @@
         uchar *p;
         int dynsize, fixsize, uncsize;
         int blocklen = s->pos - s->startpos;
- int dyntree;
+/* int dyntree; */
 
         /* calc dynamic codes */
         hufflens(llen, s->lfreq, Nlitlen, CodeBits-1);
@@ -358,7 +358,7 @@
                 if (c == 18)
                         dynsize += 7;
         }
- dyntree = dynsize - 3;
+/* dyntree = dynsize - 3; */
         for (lz = s->lzbuf, p = s->src + s->startpos; lz != s->lz; lz++)
                 if (lz->bits & LzLitFlag)
                         for (n = lz->n; n > 0; n--, p++) {
@@ -519,12 +519,12 @@
                 if (len > m.len) {
                         m.dist = s->pos - next;
                         m.len = len;
- if (len == MaxMatch)
- return m;
                         if (s->pos + len >= s->endpos) { /* TODO: overflow */
                                 m.len = s->endpos - s->pos;
                                 return m;
                         }
+ if (len == MaxMatch)
+ return m;
                 }
         } while ((next = s->chain[next % WinSize]) > limit && --chainlen);
         if (m.len < MinMatch || (m.len == MinMatch && m.dist > BigDist))
@@ -617,10 +617,9 @@
                 return s->state;
 
         guard = calcguard(s);
-/*fprintf(stderr,"guard:%d pos:%d nin:%d\n", guard, s->pos, s->inend - s->in);*/
         for (;;) {
                 if (s->pos >= guard || s->lz - s->lzbuf >= LzGuard) {
-/*fprintf(stderr,"guard:%d pos:%d len:%d lzlen:%d end:%d start:%d nin:%d\n", guard, s->pos, s->pos - s->startpos, s->lz - s->lzbuf, s->endpos, s->startpos, s->inend - s->in);*/
+/*fprintf(stderr,"guard:%d pos:%d len:%d lzlen:%d end:%d start:%d nin:%d eof:%d\n", guard, s->pos, s->pos - s->startpos, s->lz - s->lzbuf, s->endpos, s->startpos, s->inend - s->in, s->eof);*/
                         if (endblock(s))
                                 return (s->state = FlateOut);
                         if (!fillsrc(s))
Received on Sun Aug 08 2010 - 16:47:37 CEST

This archive was generated by hypermail 2.2.0 : Sun Aug 08 2010 - 16:48:04 CEST