mirror of
https://github.com/Stichting-MINIX-Research-Foundation/pkgsrc-ng.git
synced 2025-08-04 02:08:49 -04:00
31 lines
1.1 KiB
Plaintext
31 lines
1.1 KiB
Plaintext
$NetBSD: patch-ab,v 1.3 2013/06/11 08:28:30 adam Exp $
|
|
|
|
--- unpack.c.orig 2013-02-02 04:39:13.000000000 +0000
|
|
+++ unpack.c
|
|
@@ -21,7 +21,6 @@
|
|
#include "tailor.h"
|
|
#include "gzip.h"
|
|
|
|
-#define MIN(a,b) ((a) <= (b) ? (a) : (b))
|
|
/* The arguments must not have side effects. */
|
|
|
|
#define MAX_BITLEN 25
|
|
@@ -157,7 +156,7 @@ local void read_tree()
|
|
/* Remember where the literals of this length start in literal[] : */
|
|
lit_base[len] = base;
|
|
/* And read the literals: */
|
|
- for (n = leaves[len]; n > 0; n--) {
|
|
+ for (n = leaves[len]; n > 0 && base < LITERALS; n--) {
|
|
literal[base++] = read_byte ();
|
|
}
|
|
}
|
|
@@ -193,7 +192,7 @@ local void build_tree()
|
|
prefixp = &prefix_len[1<<peek_bits];
|
|
for (len = 1; len <= peek_bits; len++) {
|
|
int prefixes = leaves[len] << (peek_bits-len); /* may be 0 */
|
|
- while (prefixes--) *--prefixp = (uch)len;
|
|
+ while (prefixes-- && prefixp > prefix_len) *--prefixp = (uch)len;
|
|
}
|
|
/* The length of all other codes is unknown: */
|
|
while (prefixp > prefix_len) *--prefixp = 0;
|