zlib-streams 1.0.1 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Makefile +3 -3
- package/build/debug/src/inffast9.d +9 -0
- package/build/debug/src/inffast9.o +0 -0
- package/build/debug/src/inflate9.d +4 -1
- package/build/debug/src/inflate9.o +0 -0
- package/build/src/inffast9.d +9 -0
- package/build/src/inffast9.o +0 -0
- package/build/src/inflate9.d +4 -1
- package/build/src/inflate9.o +0 -0
- package/dist/zlib-streams.wasm +0 -0
- package/package.json +1 -1
- package/src/inffast9.c +312 -0
- package/src/inffast9.h +11 -0
- package/src/inflate9.c +159 -34
- package/tmp/all_runs/payload_decompress_nowindow_debug__100k_lines.deflate64.log +34 -0
- package/tmp/all_runs/payload_decompress_nowindow_debug__100k_lines.deflate64.out +100000 -0
- package/tmp/all_runs/payload_decompress_nowindow_debug__10k_lines.deflate64.log +2 -0
- package/tmp/all_runs/payload_decompress_nowindow_debug__10k_lines.deflate64.out +10000 -0
- package/tmp/all_runs/payload_decompress_nowindow_debug__payload_63k.deflate64.log +1 -0
- package/tmp/all_runs/payload_decompress_nowindow_debug__payload_63k.deflate64.out +0 -0
- package/tmp/all_runs/payload_decompress_nowindow_debug__payload_64k.deflate64.log +1 -0
- package/tmp/all_runs/payload_decompress_nowindow_debug__payload_64k.deflate64.out +0 -0
- package/tmp/all_runs/payload_decompress_nowindow_debug__payload_65k.deflate64.log +2 -0
- package/tmp/all_runs/payload_decompress_nowindow_debug__payload_65k.deflate64.out +0 -0
- package/tmp/all_runs/payload_decompress_nowindow_debug__rand_block_gap.deflate64.log +1 -0
- package/tmp/all_runs/payload_decompress_nowindow_debug__rand_block_gap.deflate64.out +0 -0
- package/tmp/all_runs/payload_decompress_nowindow_debug__repeat_63k.deflate64.log +1 -0
- package/tmp/all_runs/payload_decompress_nowindow_debug__repeat_63k.deflate64.out +0 -0
- package/tmp/all_runs/payload_decompress_nowindow_debug__repeat_64k.deflate64.log +1 -0
- package/tmp/all_runs/payload_decompress_nowindow_debug__repeat_64k.deflate64.out +0 -0
- package/tmp/all_runs/payload_decompress_nowindow_debug__repeat_65k.deflate64.log +2 -0
- package/tmp/all_runs/payload_decompress_nowindow_debug__repeat_65k.deflate64.out +0 -0
- package/tmp/all_runs/payload_decompress_nowindow_debug__zeros_100k.deflate64.log +2 -0
- package/tmp/all_runs/payload_decompress_nowindow_debug__zeros_100k.deflate64.out +0 -0
- package/tmp/all_runs/payload_decompress_ref_debug__100k_lines.deflate64.log +1 -0
- package/tmp/all_runs/payload_decompress_ref_debug__100k_lines.deflate64.out +100000 -0
- package/tmp/all_runs/payload_decompress_ref_debug__10k_lines.deflate64.log +1 -0
- package/tmp/all_runs/payload_decompress_ref_debug__10k_lines.deflate64.out +10000 -0
- package/tmp/all_runs/payload_decompress_ref_debug__payload_63k.deflate64.log +1 -0
- package/tmp/all_runs/payload_decompress_ref_debug__payload_63k.deflate64.out +0 -0
- package/tmp/all_runs/payload_decompress_ref_debug__payload_64k.deflate64.log +1 -0
- package/tmp/all_runs/payload_decompress_ref_debug__payload_64k.deflate64.out +0 -0
- package/tmp/all_runs/payload_decompress_ref_debug__payload_65k.deflate64.log +1 -0
- package/tmp/all_runs/payload_decompress_ref_debug__payload_65k.deflate64.out +0 -0
- package/tmp/all_runs/payload_decompress_ref_debug__rand_block_gap.deflate64.log +1 -0
- package/tmp/all_runs/payload_decompress_ref_debug__rand_block_gap.deflate64.out +0 -0
- package/tmp/all_runs/payload_decompress_ref_debug__repeat_63k.deflate64.log +1 -0
- package/tmp/all_runs/payload_decompress_ref_debug__repeat_63k.deflate64.out +0 -0
- package/tmp/all_runs/payload_decompress_ref_debug__repeat_64k.deflate64.log +1 -0
- package/tmp/all_runs/payload_decompress_ref_debug__repeat_64k.deflate64.out +0 -0
- package/tmp/all_runs/payload_decompress_ref_debug__repeat_65k.deflate64.log +1 -0
- package/tmp/all_runs/payload_decompress_ref_debug__repeat_65k.deflate64.out +0 -0
- package/tmp/all_runs/payload_decompress_ref_debug__zeros_100k.deflate64.log +1 -0
- package/tmp/all_runs/payload_decompress_ref_debug__zeros_100k.deflate64.out +0 -0
- package/tmp/all_runs/payload_decompress_test_debug__100k_lines.deflate64.log +34 -0
- package/tmp/all_runs/payload_decompress_test_debug__100k_lines.deflate64.out +100000 -0
- package/tmp/all_runs/payload_decompress_test_debug__10k_lines.deflate64.log +2 -0
- package/tmp/all_runs/payload_decompress_test_debug__10k_lines.deflate64.out +10000 -0
- package/tmp/all_runs/payload_decompress_test_debug__payload_63k.deflate64.log +1 -0
- package/tmp/all_runs/payload_decompress_test_debug__payload_63k.deflate64.out +0 -0
- package/tmp/all_runs/payload_decompress_test_debug__payload_64k.deflate64.log +1 -0
- package/tmp/all_runs/payload_decompress_test_debug__payload_64k.deflate64.out +0 -0
- package/tmp/all_runs/payload_decompress_test_debug__payload_65k.deflate64.log +2 -0
- package/tmp/all_runs/payload_decompress_test_debug__payload_65k.deflate64.out +0 -0
- package/tmp/all_runs/payload_decompress_test_debug__rand_block_gap.deflate64.log +1 -0
- package/tmp/all_runs/payload_decompress_test_debug__rand_block_gap.deflate64.out +0 -0
- package/tmp/all_runs/payload_decompress_test_debug__repeat_63k.deflate64.log +1 -0
- package/tmp/all_runs/payload_decompress_test_debug__repeat_63k.deflate64.out +0 -0
- package/tmp/all_runs/payload_decompress_test_debug__repeat_64k.deflate64.log +1 -0
- package/tmp/all_runs/payload_decompress_test_debug__repeat_64k.deflate64.out +0 -0
- package/tmp/all_runs/payload_decompress_test_debug__repeat_65k.deflate64.log +2 -0
- package/tmp/all_runs/payload_decompress_test_debug__repeat_65k.deflate64.out +0 -0
- package/tmp/all_runs/payload_decompress_test_debug__zeros_100k.deflate64.log +2 -0
- package/tmp/all_runs/payload_decompress_test_debug__zeros_100k.deflate64.out +0 -0
package/src/inflate9.c
CHANGED
|
@@ -6,9 +6,15 @@
|
|
|
6
6
|
#include "zutil.h"
|
|
7
7
|
#include "inftree9.h"
|
|
8
8
|
#include "inflate.h"
|
|
9
|
-
|
|
9
|
+
#include "inffast9.h"
|
|
10
10
|
#include "infback9.h"
|
|
11
11
|
|
|
12
|
+
#ifdef MAKEFIXED
|
|
13
|
+
#ifndef BUILDFIXED
|
|
14
|
+
#define BUILDFIXED
|
|
15
|
+
#endif
|
|
16
|
+
#endif
|
|
17
|
+
|
|
12
18
|
extern int ZEXPORT inflate9Init2_(z_streamp strm, int windowBits,
|
|
13
19
|
const char *version, int stream_size);
|
|
14
20
|
|
|
@@ -16,11 +22,6 @@ int ZEXPORT inflate9Init(z_streamp strm) {
|
|
|
16
22
|
return inflate9Init2_(strm, 16, ZLIB_VERSION, (int)sizeof(z_stream));
|
|
17
23
|
}
|
|
18
24
|
|
|
19
|
-
static unsigned in(void *in_desc, unsigned char FAR **next);
|
|
20
|
-
|
|
21
|
-
static const unsigned char order[19] = {16, 17, 18, 0, 8, 7, 9, 6, 10, 5,
|
|
22
|
-
11, 4, 12, 3, 13, 2, 14, 1, 15};
|
|
23
|
-
|
|
24
25
|
local int inflateStateCheck(z_streamp strm) {
|
|
25
26
|
struct inflate_state FAR *state;
|
|
26
27
|
if (strm == Z_NULL || strm->zalloc == (alloc_func)0 ||
|
|
@@ -88,6 +89,7 @@ int ZEXPORT inflate9Reset2(z_streamp strm, int windowBits) {
|
|
|
88
89
|
} else {
|
|
89
90
|
wrap = (windowBits >> 4) + 5;
|
|
90
91
|
}
|
|
92
|
+
|
|
91
93
|
/* set number of window bits, free window if different */
|
|
92
94
|
if (windowBits && (windowBits < 8 || windowBits > 16))
|
|
93
95
|
return Z_STREAM_ERROR;
|
|
@@ -95,6 +97,7 @@ int ZEXPORT inflate9Reset2(z_streamp strm, int windowBits) {
|
|
|
95
97
|
ZFREE(strm, state->window);
|
|
96
98
|
state->window = Z_NULL;
|
|
97
99
|
}
|
|
100
|
+
|
|
98
101
|
/* update state and reset the rest of it */
|
|
99
102
|
state->wrap = wrap;
|
|
100
103
|
state->wbits = (unsigned)windowBits;
|
|
@@ -134,7 +137,7 @@ int ZEXPORT inflate9Init2_(z_streamp strm, int windowBits, const char *version,
|
|
|
134
137
|
strm->state = (struct internal_state FAR *)state;
|
|
135
138
|
state->strm = strm;
|
|
136
139
|
state->window = Z_NULL;
|
|
137
|
-
state->mode = TYPE;
|
|
140
|
+
state->mode = TYPE; /* to pass state test in inflate9Reset2() */
|
|
138
141
|
ret = inflate9Reset2(strm, windowBits);
|
|
139
142
|
if (ret != Z_OK) {
|
|
140
143
|
ZFREE(strm, state);
|
|
@@ -148,24 +151,28 @@ int ZEXPORT inflate9Init_(z_streamp strm, const char *version,
|
|
|
148
151
|
return inflate9Init2_(strm, DEF_WBITS, version, stream_size);
|
|
149
152
|
}
|
|
150
153
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
154
|
+
/*
|
|
155
|
+
Return state with length and distance decoding tables and index sizes set to
|
|
156
|
+
fixed code decoding. Normally this returns fixed tables from inffixed.h.
|
|
157
|
+
If BUILDFIXED is defined, then instead this routine builds the tables the
|
|
158
|
+
first time it's called, and returns those tables the first time and
|
|
159
|
+
thereafter. This reduces the size of the code by about 2K bytes, in
|
|
160
|
+
exchange for a little execution time. However, BUILDFIXED should not be
|
|
161
|
+
used for threaded applications, since the rewriting of the tables and virgin
|
|
162
|
+
may not be thread-safe.
|
|
163
|
+
*/
|
|
164
|
+
local void fixedtables(struct inflate_state FAR *state) {
|
|
165
|
+
#ifdef BUILDFIXED
|
|
163
166
|
static int virgin = 1;
|
|
164
167
|
static code *lenfix, *distfix;
|
|
165
168
|
static code fixed[544];
|
|
169
|
+
|
|
170
|
+
/* build fixed huffman tables if first call (may not be thread safe) */
|
|
166
171
|
if (virgin) {
|
|
167
172
|
unsigned sym, bits;
|
|
168
173
|
static code *next;
|
|
174
|
+
|
|
175
|
+
/* literal/length table */
|
|
169
176
|
sym = 0;
|
|
170
177
|
while (sym < 144)
|
|
171
178
|
state->lens[sym++] = 8;
|
|
@@ -191,12 +198,29 @@ void fixedtables(struct inflate_state FAR *state) {
|
|
|
191
198
|
/* do this just once */
|
|
192
199
|
virgin = 0;
|
|
193
200
|
}
|
|
201
|
+
#else /* !BUILDFIXED */
|
|
202
|
+
#include "inffixed.h"
|
|
203
|
+
#endif /* BUILDFIXED */
|
|
194
204
|
state->lencode = lenfix;
|
|
195
205
|
state->lenbits = 9;
|
|
196
206
|
state->distcode = distfix;
|
|
197
207
|
state->distbits = 5;
|
|
198
208
|
}
|
|
199
209
|
|
|
210
|
+
/*
|
|
211
|
+
Update the window with the last wsize (normally 32K) bytes written before
|
|
212
|
+
returning. If window does not exist yet, create it. This is only called
|
|
213
|
+
when a window is already in use, or when output has been written during this
|
|
214
|
+
inflate call, but the end of the deflate stream has not been reached yet.
|
|
215
|
+
It is also called to create a window for dictionary data when a dictionary
|
|
216
|
+
is loaded.
|
|
217
|
+
|
|
218
|
+
Providing output buffers larger than 32K to inflate() should provide a speed
|
|
219
|
+
advantage, since only the last 32K of output is copied to the sliding window
|
|
220
|
+
upon return from inflate(), and since all distances after the first 32K of
|
|
221
|
+
output will fall in the output data, making match copies simpler and faster.
|
|
222
|
+
The advantage may be dependent on the size of the processor's data caches.
|
|
223
|
+
*/
|
|
200
224
|
local int updatewindow(z_streamp strm, const Bytef *end, unsigned copy) {
|
|
201
225
|
struct inflate_state FAR *state;
|
|
202
226
|
unsigned dist;
|
|
@@ -273,6 +297,8 @@ local int updatewindow(z_streamp strm, const Bytef *end, unsigned copy) {
|
|
|
273
297
|
bits = 0; \
|
|
274
298
|
} while (0)
|
|
275
299
|
|
|
300
|
+
/* Get a byte of input into the bit accumulator, or return from inflate()
|
|
301
|
+
if there is no input available. */
|
|
276
302
|
#define PULLBYTE() \
|
|
277
303
|
do { \
|
|
278
304
|
if (have == 0) \
|
|
@@ -282,26 +308,113 @@ local int updatewindow(z_streamp strm, const Bytef *end, unsigned copy) {
|
|
|
282
308
|
bits += 8; \
|
|
283
309
|
} while (0)
|
|
284
310
|
|
|
311
|
+
/* Assure that there are at least n bits in the bit accumulator. If there is
|
|
312
|
+
not enough available input to do that, then return from inflate(). */
|
|
285
313
|
#define NEEDBITS(n) \
|
|
286
314
|
do { \
|
|
287
315
|
while (bits < (unsigned)(n)) \
|
|
288
316
|
PULLBYTE(); \
|
|
289
317
|
} while (0)
|
|
290
318
|
|
|
319
|
+
/* Return the low n bits of the bit accumulator (n < 16) */
|
|
291
320
|
#define BITS(n) ((unsigned)hold & ((1U << (n)) - 1))
|
|
292
321
|
|
|
322
|
+
/* Remove n bits from the bit accumulator */
|
|
293
323
|
#define DROPBITS(n) \
|
|
294
324
|
do { \
|
|
295
325
|
hold >>= (n); \
|
|
296
326
|
bits -= (unsigned)(n); \
|
|
297
327
|
} while (0)
|
|
298
328
|
|
|
329
|
+
/* Remove zero to seven bits as needed to go to a byte boundary */
|
|
299
330
|
#define BYTEBITS() \
|
|
300
331
|
do { \
|
|
301
332
|
hold >>= bits & 7; \
|
|
302
333
|
bits -= bits & 7; \
|
|
303
334
|
} while (0)
|
|
304
335
|
|
|
336
|
+
/*
|
|
337
|
+
inflate() uses a state machine to process as much input data and generate as
|
|
338
|
+
much output data as possible before returning. The state machine is
|
|
339
|
+
structured roughly as follows:
|
|
340
|
+
|
|
341
|
+
for (;;) switch (state) {
|
|
342
|
+
...
|
|
343
|
+
case STATEn:
|
|
344
|
+
if (not enough input data or output space to make progress)
|
|
345
|
+
return;
|
|
346
|
+
... make progress ...
|
|
347
|
+
state = STATEm;
|
|
348
|
+
break;
|
|
349
|
+
...
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
so when inflate() is called again, the same case is attempted again, and
|
|
353
|
+
if the appropriate resources are provided, the machine proceeds to the
|
|
354
|
+
next state. The NEEDBITS() macro is usually the way the state evaluates
|
|
355
|
+
whether it can proceed or should return. NEEDBITS() does the return if
|
|
356
|
+
the requested bits are not available. The typical use of the BITS macros
|
|
357
|
+
is:
|
|
358
|
+
|
|
359
|
+
NEEDBITS(n);
|
|
360
|
+
... do something with BITS(n) ...
|
|
361
|
+
DROPBITS(n);
|
|
362
|
+
|
|
363
|
+
where NEEDBITS(n) either returns from inflate() if there isn't enough
|
|
364
|
+
input left to load n bits into the accumulator, or it continues. BITS(n)
|
|
365
|
+
gives the low n bits in the accumulator. When done, DROPBITS(n) drops
|
|
366
|
+
the low n bits off the accumulator. INITBITS() clears the accumulator
|
|
367
|
+
and sets the number of available bits to zero. BYTEBITS() discards just
|
|
368
|
+
enough bits to put the accumulator on a byte boundary. After BYTEBITS()
|
|
369
|
+
and a NEEDBITS(8), then BITS(8) would return the next byte in the stream.
|
|
370
|
+
|
|
371
|
+
NEEDBITS(n) uses PULLBYTE() to get an available byte of input, or to return
|
|
372
|
+
if there is no input available. The decoding of variable length codes uses
|
|
373
|
+
PULLBYTE() directly in order to pull just enough bytes to decode the next
|
|
374
|
+
code, and no more.
|
|
375
|
+
|
|
376
|
+
Some states loop until they get enough input, making sure that enough
|
|
377
|
+
state information is maintained to continue the loop where it left off
|
|
378
|
+
if NEEDBITS() returns in the loop. For example, want, need, and keep
|
|
379
|
+
would all have to actually be part of the saved state in case NEEDBITS()
|
|
380
|
+
returns:
|
|
381
|
+
|
|
382
|
+
case STATEw:
|
|
383
|
+
while (want < need) {
|
|
384
|
+
NEEDBITS(n);
|
|
385
|
+
keep[want++] = BITS(n);
|
|
386
|
+
DROPBITS(n);
|
|
387
|
+
}
|
|
388
|
+
state = STATEx;
|
|
389
|
+
case STATEx:
|
|
390
|
+
|
|
391
|
+
As shown above, if the next state is also the next case, then the break
|
|
392
|
+
is omitted.
|
|
393
|
+
|
|
394
|
+
A state may also return if there is not enough output space available to
|
|
395
|
+
complete that state. Those states are copying stored data, writing a
|
|
396
|
+
literal byte, and copying a matching string.
|
|
397
|
+
|
|
398
|
+
When returning, a "goto inf_leave" is used to update the total counters,
|
|
399
|
+
update the check value, and determine whether any progress has been made
|
|
400
|
+
during that inflate() call in order to return the proper return code.
|
|
401
|
+
Progress is defined as a change in either strm->avail_in or strm->avail_out.
|
|
402
|
+
When there is a window, goto inf_leave will update the window with the last
|
|
403
|
+
output written. If a goto inf_leave occurs in the middle of decompression
|
|
404
|
+
and there is no window currently, goto inf_leave will create one and copy
|
|
405
|
+
output to the window for the next call of inflate().
|
|
406
|
+
|
|
407
|
+
In this implementation, the flush parameter of inflate() only affects the
|
|
408
|
+
return code (per zlib.h). inflate() always writes as much as possible to
|
|
409
|
+
strm->next_out, given the space available and the provided input--the effect
|
|
410
|
+
documented in zlib.h of Z_SYNC_FLUSH. Furthermore, inflate() always defers
|
|
411
|
+
the allocation of and copying into a sliding window until necessary, which
|
|
412
|
+
provides the effect documented in zlib.h for Z_FINISH when the entire input
|
|
413
|
+
stream available. So the only thing the flush parameter actually does is:
|
|
414
|
+
when flush is set to Z_FINISH, inflate() cannot return Z_OK. Instead it
|
|
415
|
+
will return Z_BUF_ERROR if it has not reached the end of the stream.
|
|
416
|
+
*/
|
|
417
|
+
|
|
305
418
|
int ZEXPORT inflate9(z_streamp strm, int flush) {
|
|
306
419
|
struct inflate_state FAR *state;
|
|
307
420
|
z_const unsigned char FAR *next; /* next input */
|
|
@@ -371,7 +484,7 @@ int ZEXPORT inflate9(z_streamp strm, int flush) {
|
|
|
371
484
|
DROPBITS(2);
|
|
372
485
|
break;
|
|
373
486
|
case STORED:
|
|
374
|
-
BYTEBITS();
|
|
487
|
+
BYTEBITS(); /* go to byte boundary */
|
|
375
488
|
NEEDBITS(32);
|
|
376
489
|
if ((hold & 0xffff) != ((hold >> 16) ^ 0xffff)) {
|
|
377
490
|
strm->msg = (z_const char *)"invalid stored block lengths";
|
|
@@ -416,11 +529,13 @@ int ZEXPORT inflate9(z_streamp strm, int flush) {
|
|
|
416
529
|
DROPBITS(5);
|
|
417
530
|
state->ncode = BITS(4) + 4;
|
|
418
531
|
DROPBITS(4);
|
|
532
|
+
#ifndef PKZIP_BUG_WORKAROUND
|
|
419
533
|
if (state->nlen > 286) {
|
|
420
|
-
strm->msg = (z_const char *)"too many length
|
|
534
|
+
strm->msg = (z_const char *)"too many length symbols";
|
|
421
535
|
state->mode = BAD;
|
|
422
536
|
break;
|
|
423
537
|
}
|
|
538
|
+
#endif
|
|
424
539
|
Tracev((stderr, "inflate: table sizes ok\n"));
|
|
425
540
|
state->have = 0;
|
|
426
541
|
state->mode = LENLENS;
|
|
@@ -504,8 +619,12 @@ int ZEXPORT inflate9(z_streamp strm, int flush) {
|
|
|
504
619
|
break;
|
|
505
620
|
}
|
|
506
621
|
|
|
622
|
+
/* build code tables -- note: do not change the lenbits or distbits
|
|
623
|
+
values here (9 and 6) without reading the comments in inftrees.h
|
|
624
|
+
concerning the ENOUGH constants, which depend on those values */
|
|
507
625
|
state->next = state->codes;
|
|
508
626
|
state->lencode = (const code FAR *)(state->next);
|
|
627
|
+
state->lenbits = 9;
|
|
509
628
|
ret = inflate_table9(LENS, state->lens, state->nlen, &(state->next),
|
|
510
629
|
&(state->lenbits), state->work);
|
|
511
630
|
if (ret) {
|
|
@@ -514,6 +633,7 @@ int ZEXPORT inflate9(z_streamp strm, int flush) {
|
|
|
514
633
|
break;
|
|
515
634
|
}
|
|
516
635
|
state->distcode = (const code FAR *)(state->next);
|
|
636
|
+
state->distbits = 6;
|
|
517
637
|
ret = inflate_table9(DISTS, state->lens + state->nlen, state->ndist,
|
|
518
638
|
&(state->next), &(state->distbits), state->work);
|
|
519
639
|
if (ret) {
|
|
@@ -530,6 +650,14 @@ int ZEXPORT inflate9(z_streamp strm, int flush) {
|
|
|
530
650
|
state->mode = LEN;
|
|
531
651
|
/* fallthrough */
|
|
532
652
|
case LEN:
|
|
653
|
+
if (have >= 6 && left >= 65536) {
|
|
654
|
+
RESTORE();
|
|
655
|
+
inflate_fast9(strm, out);
|
|
656
|
+
LOAD();
|
|
657
|
+
if (state->mode == TYPE)
|
|
658
|
+
state->back = -1;
|
|
659
|
+
break;
|
|
660
|
+
}
|
|
533
661
|
state->back = 0;
|
|
534
662
|
for (;;) {
|
|
535
663
|
here = state->lencode[BITS(state->lenbits)];
|
|
@@ -623,11 +751,13 @@ int ZEXPORT inflate9(z_streamp strm, int flush) {
|
|
|
623
751
|
DROPBITS(state->extra);
|
|
624
752
|
state->back += state->extra;
|
|
625
753
|
}
|
|
754
|
+
#ifdef INFLATE_STRICT
|
|
626
755
|
if (state->offset > state->dmax) {
|
|
627
756
|
strm->msg = (z_const char *)"invalid distance too far back";
|
|
628
757
|
state->mode = BAD;
|
|
629
758
|
break;
|
|
630
759
|
}
|
|
760
|
+
#endif
|
|
631
761
|
Tracevv((stderr, "inflate: distance %u\n", state->offset));
|
|
632
762
|
state->mode = MATCH;
|
|
633
763
|
/* fallthrough */
|
|
@@ -644,6 +774,7 @@ int ZEXPORT inflate9(z_streamp strm, int flush) {
|
|
|
644
774
|
break;
|
|
645
775
|
}
|
|
646
776
|
#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR
|
|
777
|
+
Trace((stderr, "inflate.c too far\n"));
|
|
647
778
|
copy -= state->whave;
|
|
648
779
|
if (copy > state->length)
|
|
649
780
|
copy = state->length;
|
|
@@ -697,8 +828,13 @@ int ZEXPORT inflate9(z_streamp strm, int flush) {
|
|
|
697
828
|
return Z_STREAM_ERROR;
|
|
698
829
|
}
|
|
699
830
|
|
|
831
|
+
/*
|
|
832
|
+
Return from inflate9(), updating the total counts and the check value.
|
|
833
|
+
If there was no progress during the inflate9() call, return a buffer
|
|
834
|
+
error. Call updatewindow() to create and/or update the window state.
|
|
835
|
+
Note: a memory error from inflate9() is non-recoverable.
|
|
836
|
+
*/
|
|
700
837
|
inf_leave:
|
|
701
|
-
state->hold = hold;
|
|
702
838
|
RESTORE();
|
|
703
839
|
if (state->wsize || (out != strm->avail_out && state->mode < BAD &&
|
|
704
840
|
(state->mode < DONE || flush != Z_FINISH)))
|
|
@@ -719,15 +855,4 @@ inf_leave:
|
|
|
719
855
|
return ret;
|
|
720
856
|
}
|
|
721
857
|
|
|
722
|
-
int ZEXPORT inflate9End(z_streamp strm) {
|
|
723
|
-
struct inflate_state FAR *state;
|
|
724
|
-
if (inflateStateCheck(strm))
|
|
725
|
-
return Z_STREAM_ERROR;
|
|
726
|
-
state = (struct inflate_state FAR *)strm->state;
|
|
727
|
-
if (state->window != Z_NULL)
|
|
728
|
-
ZFREE(strm, state->window);
|
|
729
|
-
ZFREE(strm, strm->state);
|
|
730
|
-
strm->state = Z_NULL;
|
|
731
|
-
Tracev((stderr, "inflate: end\n"));
|
|
732
|
-
return Z_OK;
|
|
733
|
-
}
|
|
858
|
+
int ZEXPORT inflate9End(z_streamp strm) { return inflateEnd(strm); }
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
inflate9 nowindow loop ret=0 produced=65536
|
|
2
|
+
inflate9 nowindow loop ret=0 produced=65536
|
|
3
|
+
inflate9 nowindow loop ret=0 produced=65536
|
|
4
|
+
inflate9 nowindow loop ret=0 produced=65536
|
|
5
|
+
inflate9 nowindow loop ret=0 produced=65536
|
|
6
|
+
inflate9 nowindow loop ret=0 produced=65536
|
|
7
|
+
inflate9 nowindow loop ret=0 produced=65536
|
|
8
|
+
inflate9 nowindow loop ret=0 produced=65536
|
|
9
|
+
inflate9 nowindow loop ret=0 produced=65536
|
|
10
|
+
inflate9 nowindow loop ret=0 produced=65536
|
|
11
|
+
inflate9 nowindow loop ret=0 produced=65536
|
|
12
|
+
inflate9 nowindow loop ret=0 produced=65536
|
|
13
|
+
inflate9 nowindow loop ret=0 produced=65536
|
|
14
|
+
inflate9 nowindow loop ret=0 produced=65536
|
|
15
|
+
inflate9 nowindow loop ret=0 produced=65536
|
|
16
|
+
inflate9 nowindow loop ret=0 produced=65536
|
|
17
|
+
inflate9 nowindow loop ret=0 produced=65536
|
|
18
|
+
inflate9 nowindow loop ret=0 produced=65536
|
|
19
|
+
inflate9 nowindow loop ret=0 produced=65536
|
|
20
|
+
inflate9 nowindow loop ret=0 produced=65536
|
|
21
|
+
inflate9 nowindow loop ret=0 produced=65536
|
|
22
|
+
inflate9 nowindow loop ret=0 produced=65536
|
|
23
|
+
inflate9 nowindow loop ret=0 produced=65536
|
|
24
|
+
inflate9 nowindow loop ret=0 produced=65536
|
|
25
|
+
inflate9 nowindow loop ret=0 produced=65536
|
|
26
|
+
inflate9 nowindow loop ret=0 produced=65536
|
|
27
|
+
inflate9 nowindow loop ret=0 produced=65536
|
|
28
|
+
inflate9 nowindow loop ret=0 produced=65536
|
|
29
|
+
inflate9 nowindow loop ret=0 produced=65536
|
|
30
|
+
inflate9 nowindow loop ret=0 produced=65536
|
|
31
|
+
inflate9 nowindow loop ret=0 produced=65536
|
|
32
|
+
inflate9 nowindow loop ret=0 produced=65536
|
|
33
|
+
inflate9 nowindow loop ret=0 produced=65536
|
|
34
|
+
inflate9 nowindow loop ret=1 produced=26202
|