]> git.pld-linux.org Git - packages/links.git/commitdiff
- some content_encoding patch fixes
authorJakub Bogusz <qboosh@pld-linux.org>
Tue, 8 Sep 2020 20:13:32 +0000 (22:13 +0200)
committerJakub Bogusz <qboosh@pld-linux.org>
Tue, 8 Sep 2020 20:13:32 +0000 (22:13 +0200)
links-content_encoding.patch

index c3fb52983ca24e9f1189034257338d0b62d66659..8a9f4d04f0071cc13af12061c6c24f6effffd803 100644 (file)
@@ -11,7 +11,7 @@
  LIBS = @LIBS@
 --- /dev/null  Tue May  5 22:32:27 1998
 +++ links-0.97.newer/compress.c        Wed Jul  3 19:28:29 2002
-@@ -0,0 +1,164 @@
+@@ -0,0 +1,169 @@
 +#include "links.h"
 +
 +#define WMAXBITS 15
@@ -45,7 +45,7 @@
 +  int ret;
 +  z_streamp z;
 +
-+  if (buf[0] != 0x1f || buf[1] != 0x8b) return NULL;
++  if ((l < 10) || buf[0] != 0x1f || buf[1] != 0x8b) return NULL;
 +
 +  method = buf[2];
 +  flags = buf[3];
 +  l -= 10;
 +
 +  if ((flags & EXTRA_FIELD) != 0) { /* skip the extra field */
++     if (l < 2) return NULL;
 +     len  =  2 + buf[0] + (buf[1] << 8);
 +     buf += len;
 +     l -= len;
 +  }
-+  if (l <= 0) return NULL;
++  if (l < 0) return NULL;
 +
 +  if ((flags & ORIG_NAME) != 0) {/* skip the original file name */
-+     len = strlen(buf) + 1;
++     len = strnlen(buf, l) + 1;
 +     buf += len;
 +     l -= len;
 +  }
-+  if (l <= 0) return NULL;
++  if (l < 0) return NULL;
 +
 +  if ((flags & COMMENT) != 0) {/* skip the .gz file comment */
-+     len = strlen(buf) + 1;
++     len = strnlen(buf, l) + 1;
 +     buf += len;
 +     l -= len;
 +  }
-+  if (l <= 0) return NULL;
++  if (l < 0) return NULL;
 +
 +  if ((flags & HEAD_CRC) != 0) {  /* skip the header crc */
 +     buf += 2;
 +     l -= 2;
 +  }
-+  if (l <= 0) return NULL;
++  if (l < 0) return NULL;
 +
 +/* initialization of z_stream */
 +  z = (z_streamp)mem_alloc(sizeof(z_stream));
 +         *dl = -1;
 +         return NULL;
 +      }
++      if ((*z)->avail_in == 0) {
++         *dl = 0;
++         return NULL;
++      }
 +   }
 +   else {
 +      (*z)->next_in = buf;
 +                      if (c->gzip) {
 +                              int dl;
 +                              unsigned char *data = decompress_gzip(&c->z, rb->data, l, &dl);
-+                              if (!data) {
++                              if (!data && (dl < 0)) {
 +                                      setcstate(c, S_OUT_OF_MEM);
 +                                      abort_connection(c);
 +                                      return;
 +                              }
 +                              if (add_fragment(c->cache, c->from, data, dl) == 1) c->tries = 0;
-+                              mem_free(data);
++                              if (data) mem_free(data);
 +                              c->from += dl;
 +                      } else {
 +                              if (add_fragment(c->cache, c->from, rb->data, l) == 1) c->tries = 0;
 -                      if (add_fragment(c->cache, c->from, rb->data, l) == 1) c->tries = 0;
                        info->chunk_remaining -= l;
 -                      c->from += l;
-+                      if (c->gzip) {
++                      if (c->gzip && (l > 0)) {
 +                              int dl;
 +                              unsigned char *data = decompress_gzip(&c->z, rb->data, l, &dl);
-+                              if (!data) {
++                              if (!data && (dl < 0)) {
 +                                      setcstate(c, S_OUT_OF_MEM);
 +                                      abort_connection(c);
 +                                      return;
 +                              }
 +                              if (add_fragment(c->cache, c->from, data, dl) == 1) c->tries = 0;
-+                              mem_free(data);
++                              if (data) mem_free(data);
 +                              c->from += dl;
 +                      } else {
 +                              if (add_fragment(c->cache, c->from, rb->data, l) == 1) c->tries = 0;
This page took 0.142028 seconds and 4 git commands to generate.