#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "misc/util/abc_global.h"
#include "zutil.h"
#include "inftrees.h"
#include "inflate.h"
#include "inffast.h"
Go to the source code of this file.
|
#define | OFF 1 |
|
#define | PUP(a) *++(a) |
|
Definition at line 74 of file inffast.c.
77 unsigned char FAR *in;
79 unsigned char FAR *out;
80 unsigned char FAR *beg;
81 unsigned char FAR *end;
100 unsigned char FAR *from;
104 in = strm->next_in -
OFF;
105 last = in + (strm->avail_in - 5);
106 out = strm->next_out -
OFF;
107 beg = out - (start - strm->avail_out);
108 end = out + (strm->avail_out - 257);
109 #ifdef INFLATE_STRICT
112 wsize = state->
wsize;
113 whave = state->
whave;
114 wnext = state->
wnext;
120 lmask = (1U << state->
lenbits) - 1;
121 dmask = (1U << state->
distbits) - 1;
127 hold += (
unsigned long)(
PUP(in)) << bits;
129 hold += (
unsigned long)(
PUP(in)) << bits;
132 here = lcode[hold & lmask];
134 op = (unsigned)(here.
bits);
137 op = (unsigned)(here.
op);
140 "inflate: literal '%c'\n" :
141 "inflate: literal 0x%02x\n", here.
val));
142 PUP(out) = (
unsigned char)(here.
val);
145 len = (unsigned)(here.
val);
149 hold += (
unsigned long)(
PUP(in)) << bits;
152 len += (unsigned)hold & ((1U << op) - 1);
156 Tracevv((stderr,
"inflate: length %u\n", len));
158 hold += (
unsigned long)(
PUP(in)) << bits;
160 hold += (
unsigned long)(
PUP(in)) << bits;
163 here = dcode[hold & dmask];
165 op = (unsigned)(here.
bits);
168 op = (unsigned)(here.
op);
170 dist = (unsigned)(here.
val);
173 hold += (
unsigned long)(
PUP(in)) << bits;
176 hold += (
unsigned long)(
PUP(in)) << bits;
180 dist += (unsigned)hold & ((1U << op) - 1);
181 #ifdef INFLATE_STRICT
183 strm->msg = (
char *)
"invalid distance too far back";
190 Tracevv((stderr,
"inflate: distance %u\n", dist));
191 op = (unsigned)(out - beg);
197 (
char *)
"invalid distance too far back";
201 #ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR
202 if (len <= op - whave) {
211 }
while (--op > whave);
232 else if (wnext < op) {
233 from += wsize + wnext - op;
288 else if ((op & 64) == 0) {
289 here = dcode[here.
val + (hold & ((1U << op) - 1))];
293 strm->msg = (
char *)
"invalid distance code";
298 else if ((op & 64) == 0) {
299 here = lcode[here.
val + (hold & ((1U << op) - 1))];
303 Tracevv((stderr,
"inflate: end of block\n"));
308 strm->msg = (
char *)
"invalid literal/length code";
312 }
while (in < last && out < end);
318 hold &= (1U <<
bits) - 1;
321 strm->next_in = in +
OFF;
322 strm->next_out = out +
OFF;
323 strm->avail_in = (unsigned)(in < last ? 5 + (last - in) : 5 - (in -
last));
324 strm->avail_out = (unsigned)(out < end ?
325 257 + (end - out) : 257 - (out - end));
code const FAR * distcode
unsigned char FAR * window
static char * bits(int n)