diff options
Diffstat (limited to 'infblock.c')
-rw-r--r-- | infblock.c | 31 |
1 files changed, 20 insertions, 11 deletions
@@ -139,7 +139,7 @@ int r; | |||
139 | break; | 139 | break; |
140 | case 3: /* illegal */ | 140 | case 3: /* illegal */ |
141 | DUMPBITS(3) | 141 | DUMPBITS(3) |
142 | s->mode = ERROR; | 142 | s->mode = INF_ERROR; |
143 | z->msg = "invalid block type"; | 143 | z->msg = "invalid block type"; |
144 | r = Z_DATA_ERROR; | 144 | r = Z_DATA_ERROR; |
145 | LEAVE | 145 | LEAVE |
@@ -149,7 +149,7 @@ int r; | |||
149 | NEEDBITS(32) | 149 | NEEDBITS(32) |
150 | if ((~b) >> 16 != (b & 0xffff)) | 150 | if ((~b) >> 16 != (b & 0xffff)) |
151 | { | 151 | { |
152 | s->mode = ERROR; | 152 | s->mode = INF_ERROR; |
153 | z->msg = "invalid stored block lengths"; | 153 | z->msg = "invalid stored block lengths"; |
154 | r = Z_DATA_ERROR; | 154 | r = Z_DATA_ERROR; |
155 | LEAVE | 155 | LEAVE |
@@ -172,7 +172,7 @@ int r; | |||
172 | #ifndef PKZIP_BUG_WORKAROUND | 172 | #ifndef PKZIP_BUG_WORKAROUND |
173 | if ((t & 0x1f) > 29 || ((t >> 5) & 0x1f) > 29) | 173 | if ((t & 0x1f) > 29 || ((t >> 5) & 0x1f) > 29) |
174 | { | 174 | { |
175 | s->mode = ERROR; | 175 | s->mode = INF_ERROR; |
176 | z->msg = "too many length or distance symbols"; | 176 | z->msg = "too many length or distance symbols"; |
177 | r = Z_DATA_ERROR; | 177 | r = Z_DATA_ERROR; |
178 | LEAVE | 178 | LEAVE |
@@ -205,7 +205,7 @@ int r; | |||
205 | { | 205 | { |
206 | r = t; | 206 | r = t; |
207 | if (r == Z_DATA_ERROR) | 207 | if (r == Z_DATA_ERROR) |
208 | s->mode = ERROR; | 208 | s->mode = INF_ERROR; |
209 | LEAVE | 209 | LEAVE |
210 | } | 210 | } |
211 | s->sub.trees.index = 0; | 211 | s->sub.trees.index = 0; |
@@ -240,7 +240,7 @@ int r; | |||
240 | if (i + j > 258 + (t & 0x1f) + ((t >> 5) & 0x1f) || | 240 | if (i + j > 258 + (t & 0x1f) + ((t >> 5) & 0x1f) || |
241 | (c == 16 && i < 1)) | 241 | (c == 16 && i < 1)) |
242 | { | 242 | { |
243 | s->mode = ERROR; | 243 | s->mode = INF_ERROR; |
244 | z->msg = "invalid bit length repeat"; | 244 | z->msg = "invalid bit length repeat"; |
245 | r = Z_DATA_ERROR; | 245 | r = Z_DATA_ERROR; |
246 | LEAVE | 246 | LEAVE |
@@ -267,7 +267,7 @@ int r; | |||
267 | if (t != Z_OK) | 267 | if (t != Z_OK) |
268 | { | 268 | { |
269 | if (t == (uInt)Z_DATA_ERROR) | 269 | if (t == (uInt)Z_DATA_ERROR) |
270 | s->mode = ERROR; | 270 | s->mode = INF_ERROR; |
271 | r = t; | 271 | r = t; |
272 | LEAVE | 272 | LEAVE |
273 | } | 273 | } |
@@ -289,8 +289,19 @@ int r; | |||
289 | r = Z_OK; | 289 | r = Z_OK; |
290 | inflate_codes_free(s->sub.codes, z); | 290 | inflate_codes_free(s->sub.codes, z); |
291 | LOAD | 291 | LOAD |
292 | s->mode = s->last ? DRY : TYPE; | 292 | if (!s->last) |
293 | { | ||
294 | s->mode = TYPE; | ||
293 | break; | 295 | break; |
296 | } | ||
297 | if (k > 7) /* return unused byte, if any */ | ||
298 | { | ||
299 | Assert(k < 16, "inflate_codes grabbed too many bytes") | ||
300 | k -= 8; | ||
301 | n++; | ||
302 | p--; /* can always return one */ | ||
303 | } | ||
304 | s->mode = DRY; | ||
294 | case DRY: | 305 | case DRY: |
295 | FLUSH | 306 | FLUSH |
296 | if (s->read != s->write) | 307 | if (s->read != s->write) |
@@ -299,7 +310,7 @@ int r; | |||
299 | case DONE: | 310 | case DONE: |
300 | r = Z_STREAM_END; | 311 | r = Z_STREAM_END; |
301 | LEAVE | 312 | LEAVE |
302 | case ERROR: | 313 | case INF_ERROR: |
303 | r = Z_DATA_ERROR; | 314 | r = Z_DATA_ERROR; |
304 | LEAVE | 315 | LEAVE |
305 | default: | 316 | default: |
@@ -309,13 +320,11 @@ int r; | |||
309 | } | 320 | } |
310 | 321 | ||
311 | 322 | ||
312 | int inflate_blocks_free(s, z, c, e) | 323 | int inflate_blocks_free(s, z, c) |
313 | struct inflate_blocks_state *s; | 324 | struct inflate_blocks_state *s; |
314 | z_stream *z; | 325 | z_stream *z; |
315 | uLong *c; | 326 | uLong *c; |
316 | int *e; | ||
317 | { | 327 | { |
318 | *e = (int)(s->bitk > 7 ? (s->bitb >> (s->bitk & 7)) & 0xff : -1); | ||
319 | if (s->checkfn != Z_NULL) | 328 | if (s->checkfn != Z_NULL) |
320 | *c = s->check; | 329 | *c = s->check; |
321 | if (s->mode == BTREE || s->mode == DTREE) | 330 | if (s->mode == BTREE || s->mode == DTREE) |