1 |
commit: 82a01ddf94b5d5b13195c7b6f58134e00fa84c8a |
2 |
Author: Mike Frysinger <vapier <AT> gentoo <DOT> org> |
3 |
AuthorDate: Wed Dec 2 05:17:05 2015 +0000 |
4 |
Commit: Mike Frysinger <vapier <AT> gentoo <DOT> org> |
5 |
CommitDate: Wed Dec 2 05:20:29 2015 +0000 |
6 |
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=82a01ddf |
7 |
|
8 |
sys-apps/busybox: add upstream fix for unzip regression |
9 |
|
10 |
.../files/busybox-1.24.1-unzip-regression.patch | 135 +++++++++++++++++++++ |
11 |
1 file changed, 135 insertions(+) |
12 |
|
13 |
diff --git a/sys-apps/busybox/files/busybox-1.24.1-unzip-regression.patch b/sys-apps/busybox/files/busybox-1.24.1-unzip-regression.patch |
14 |
new file mode 100644 |
15 |
index 0000000..58d7b7c |
16 |
--- /dev/null |
17 |
+++ b/sys-apps/busybox/files/busybox-1.24.1-unzip-regression.patch |
18 |
@@ -0,0 +1,135 @@ |
19 |
+From 092fabcf1df5d46cd22be4ffcd3b871f6180eb9c Mon Sep 17 00:00:00 2001 |
20 |
+From: Denys Vlasenko <vda.linux@××××××××××.com> |
21 |
+Date: Fri, 30 Oct 2015 23:41:53 +0100 |
22 |
+Subject: [PATCH] [g]unzip: fix recent breakage. |
23 |
+ |
24 |
+Also, do emit error message we so painstakingly pass from gzip internals |
25 |
+ |
26 |
+Signed-off-by: Denys Vlasenko <vda.linux@××××××××××.com> |
27 |
+(cherry picked from commit 6bd3fff51aa74e2ee2d87887b12182a3b09792ef) |
28 |
+Signed-off-by: Mike Frysinger <vapier@g.o> |
29 |
+--- |
30 |
+ archival/libarchive/decompress_gunzip.c | 33 +++++++++++++++++++++------------ |
31 |
+ testsuite/unzip.tests | 1 + |
32 |
+ 2 files changed, 22 insertions(+), 12 deletions(-) |
33 |
+ |
34 |
+diff --git a/archival/libarchive/decompress_gunzip.c b/archival/libarchive/decompress_gunzip.c |
35 |
+index c76fd31..357c9bf 100644 |
36 |
+--- a/archival/libarchive/decompress_gunzip.c |
37 |
++++ b/archival/libarchive/decompress_gunzip.c |
38 |
+@@ -309,8 +309,7 @@ static int huft_build(const unsigned *b, const unsigned n, |
39 |
+ huft_t *q; /* points to current table */ |
40 |
+ huft_t r; /* table entry for structure assignment */ |
41 |
+ huft_t *u[BMAX]; /* table stack */ |
42 |
+- unsigned v[N_MAX]; /* values in order of bit length */ |
43 |
+- unsigned v_end; |
44 |
++ unsigned v[N_MAX + 1]; /* values in order of bit length. last v[] is never used */ |
45 |
+ int ws[BMAX + 1]; /* bits decoded stack */ |
46 |
+ int w; /* bits decoded */ |
47 |
+ unsigned x[BMAX + 1]; /* bit offsets, then code stack */ |
48 |
+@@ -365,15 +364,17 @@ static int huft_build(const unsigned *b, const unsigned n, |
49 |
+ *xp++ = j; |
50 |
+ } |
51 |
+ |
52 |
+- /* Make a table of values in order of bit lengths */ |
53 |
++ /* Make a table of values in order of bit lengths. |
54 |
++ * To detect bad input, unused v[i]'s are set to invalid value UINT_MAX. |
55 |
++ * In particular, last v[i] is never filled and must not be accessed. |
56 |
++ */ |
57 |
++ memset(v, 0xff, sizeof(v)); |
58 |
+ p = b; |
59 |
+ i = 0; |
60 |
+- v_end = 0; |
61 |
+ do { |
62 |
+ j = *p++; |
63 |
+ if (j != 0) { |
64 |
+ v[x[j]++] = i; |
65 |
+- v_end = x[j]; |
66 |
+ } |
67 |
+ } while (++i < n); |
68 |
+ |
69 |
+@@ -435,7 +436,9 @@ static int huft_build(const unsigned *b, const unsigned n, |
70 |
+ |
71 |
+ /* set up table entry in r */ |
72 |
+ r.b = (unsigned char) (k - w); |
73 |
+- if (p >= v + v_end) { // Was "if (p >= v + n)" but v[] can be shorter! |
74 |
++ if (/*p >= v + n || -- redundant, caught by the second check: */ |
75 |
++ *p == UINT_MAX /* do we access uninited v[i]? (see memset(v))*/ |
76 |
++ ) { |
77 |
+ r.e = 99; /* out of values--invalid code */ |
78 |
+ } else if (*p < s) { |
79 |
+ r.e = (unsigned char) (*p < 256 ? 16 : 15); /* 256 is EOB code */ |
80 |
+@@ -520,8 +523,9 @@ static NOINLINE int inflate_codes(STATE_PARAM_ONLY) |
81 |
+ e = t->e; |
82 |
+ if (e > 16) |
83 |
+ do { |
84 |
+- if (e == 99) |
85 |
+- abort_unzip(PASS_STATE_ONLY);; |
86 |
++ if (e == 99) { |
87 |
++ abort_unzip(PASS_STATE_ONLY); |
88 |
++ } |
89 |
+ bb >>= t->b; |
90 |
+ k -= t->b; |
91 |
+ e -= 16; |
92 |
+@@ -557,8 +561,9 @@ static NOINLINE int inflate_codes(STATE_PARAM_ONLY) |
93 |
+ e = t->e; |
94 |
+ if (e > 16) |
95 |
+ do { |
96 |
+- if (e == 99) |
97 |
++ if (e == 99) { |
98 |
+ abort_unzip(PASS_STATE_ONLY); |
99 |
++ } |
100 |
+ bb >>= t->b; |
101 |
+ k -= t->b; |
102 |
+ e -= 16; |
103 |
+@@ -824,8 +829,9 @@ static int inflate_block(STATE_PARAM smallint *e) |
104 |
+ |
105 |
+ b_dynamic >>= 4; |
106 |
+ k_dynamic -= 4; |
107 |
+- if (nl > 286 || nd > 30) |
108 |
++ if (nl > 286 || nd > 30) { |
109 |
+ abort_unzip(PASS_STATE_ONLY); /* bad lengths */ |
110 |
++ } |
111 |
+ |
112 |
+ /* read in bit-length-code lengths */ |
113 |
+ for (j = 0; j < nb; j++) { |
114 |
+@@ -906,12 +912,14 @@ static int inflate_block(STATE_PARAM smallint *e) |
115 |
+ bl = lbits; |
116 |
+ |
117 |
+ i = huft_build(ll, nl, 257, cplens, cplext, &inflate_codes_tl, &bl); |
118 |
+- if (i != 0) |
119 |
++ if (i != 0) { |
120 |
+ abort_unzip(PASS_STATE_ONLY); |
121 |
++ } |
122 |
+ bd = dbits; |
123 |
+ i = huft_build(ll + nl, nd, 0, cpdist, cpdext, &inflate_codes_td, &bd); |
124 |
+- if (i != 0) |
125 |
++ if (i != 0) { |
126 |
+ abort_unzip(PASS_STATE_ONLY); |
127 |
++ } |
128 |
+ |
129 |
+ /* set up data for inflate_codes() */ |
130 |
+ inflate_codes_setup(PASS_STATE bl, bd); |
131 |
+@@ -999,6 +1007,7 @@ inflate_unzip_internal(STATE_PARAM transformer_state_t *xstate) |
132 |
+ error_msg = "corrupted data"; |
133 |
+ if (setjmp(error_jmp)) { |
134 |
+ /* Error from deep inside zip machinery */ |
135 |
++ bb_error_msg(error_msg); |
136 |
+ n = -1; |
137 |
+ goto ret; |
138 |
+ } |
139 |
+diff --git a/testsuite/unzip.tests b/testsuite/unzip.tests |
140 |
+index ca0a458..d8738a3 100755 |
141 |
+--- a/testsuite/unzip.tests |
142 |
++++ b/testsuite/unzip.tests |
143 |
+@@ -34,6 +34,7 @@ rm foo.zip |
144 |
+ testing "unzip (bad archive)" "uudecode; unzip bad.zip 2>&1; echo \$?" \ |
145 |
+ "Archive: bad.zip |
146 |
+ inflating: ]3j½r«IK-%Ix |
147 |
++unzip: corrupted data |
148 |
+ unzip: inflate error |
149 |
+ 1 |
150 |
+ " \ |
151 |
+-- |
152 |
+2.6.2 |
153 |
+ |