611 unsigned char FAR *put;
617 unsigned char FAR *from;
623 unsigned char hbuf[4];
625 static const unsigned short order[19] =
626 {16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15};
639 switch (state->
mode) {
641 if (state->
wrap == 0) {
647 if ((state->
wrap & 2) && hold == 0x8b1f) {
657 if (!(state->
wrap & 1) ||
661 ((
BITS(8) << 8) + (hold >> 8)) % 31) {
662 strm->
msg = (
char *)
"incorrect header check";
667 strm->
msg = (
char *)
"unknown compression method";
673 if (state->
wbits == 0)
675 else if (len > state->
wbits) {
676 strm->
msg = (
char *)
"invalid window size";
680 state->
dmax = 1U << len;
681 Tracev((stderr,
"inflate: zlib header ok\n"));
689 state->
flags = (int)(hold);
691 strm->
msg = (
char *)
"unknown compression method";
695 if (state->
flags & 0xe000) {
696 strm->
msg = (
char *)
"unknown header flags set";
701 state->
head->
text = (int)((hold >> 8) & 1);
716 state->
head->
os = (int)(hold >> 8);
722 if (state->
flags & 0x0400) {
724 state->
length = (unsigned)(hold);
734 if (state->
flags & 0x0400) {
736 if (copy > have) copy =
have;
745 if (state->
flags & 0x0200)
751 if (state->
length)
goto inf_leave;
756 if (state->
flags & 0x0800) {
757 if (have == 0)
goto inf_leave;
760 len = (unsigned)(next[copy++]);
765 }
while (len && copy < have);
766 if (state->
flags & 0x0200)
770 if (len)
goto inf_leave;
777 if (state->
flags & 0x1000) {
778 if (have == 0)
goto inf_leave;
781 len = (unsigned)(next[copy++]);
786 }
while (len && copy < have);
787 if (state->
flags & 0x0200)
791 if (len)
goto inf_leave;
797 if (state->
flags & 0x0200) {
799 if (hold != (state->
check & 0xffff)) {
800 strm->
msg = (
char *)
"header crc mismatch";
839 Tracev((stderr,
"inflate: stored block%s\n",
840 state->
last ?
" (last)" :
""));
845 Tracev((stderr,
"inflate: fixed codes block%s\n",
846 state->
last ?
" (last)" :
""));
854 Tracev((stderr,
"inflate: dynamic codes block%s\n",
855 state->
last ?
" (last)" :
""));
859 strm->
msg = (
char *)
"invalid block type";
867 if ((hold & 0xffff) != ((hold >> 16) ^ 0xffff)) {
868 strm->
msg = (
char *)
"invalid stored block lengths";
872 state->
length = (unsigned)hold & 0xffff;
873 Tracev((stderr,
"inflate: stored length %u\n",
877 if (flush ==
Z_TREES)
goto inf_leave;
883 if (copy > have) copy =
have;
884 if (copy > left) copy = left;
885 if (copy == 0)
goto inf_leave;
894 Tracev((stderr,
"inflate: stored end\n"));
905 #ifndef PKZIP_BUG_WORKAROUND 906 if (state->
nlen > 286 || state->
ndist > 30) {
907 strm->
msg = (
char *)
"too many length or distance symbols";
912 Tracev((stderr,
"inflate: table sizes ok\n"));
918 state->
lens[order[state->
have++]] = (
unsigned short)
BITS(3);
921 while (state->
have < 19)
922 state->
lens[order[state->
have++]] = 0;
929 strm->
msg = (
char *)
"invalid code lengths set";
933 Tracev((stderr,
"inflate: code lengths ok\n"));
940 if ((
unsigned)(here.
bits) <= bits)
break;
948 if (here.
val == 16) {
951 if (state->
have == 0) {
952 strm->
msg = (
char *)
"invalid bit length repeat";
960 else if (here.
val == 17) {
975 strm->
msg = (
char *)
"invalid bit length repeat";
980 state->
lens[state->
have++] = (
unsigned short)len;
988 if (state->
lens[256] == 0) {
989 strm->
msg = (
char *)
"invalid code -- missing end-of-block";
1003 strm->
msg = (
char *)
"invalid literal/lengths set";
1012 strm->
msg = (
char *)
"invalid distances set";
1016 Tracev((stderr,
"inflate: codes ok\n"));
1018 if (flush ==
Z_TREES)
goto inf_leave;
1022 if (have >= 6 && left >= 258) {
1033 if ((
unsigned)(here.
bits) <= bits)
break;
1036 if (here.
op && (here.
op & 0xf0) == 0) {
1041 if ((
unsigned)(last.
bits + here.
bits) <= bits)
break;
1050 if ((
int)(here.
op) == 0) {
1052 "inflate: literal '%c'\n" :
1053 "inflate: literal 0x%02x\n", here.
val));
1058 Tracevv((stderr,
"inflate: end of block\n"));
1064 strm->
msg = (
char *)
"invalid literal/length code";
1068 state->
extra = (unsigned)(here.
op) & 15;
1083 if ((
unsigned)(here.
bits) <= bits)
break;
1086 if ((here.
op & 0xf0) == 0) {
1091 if ((
unsigned)(last.
bits + here.
bits) <= bits)
break;
1100 strm->
msg = (
char *)
"invalid distance code";
1105 state->
extra = (
unsigned)(here.
op) & 15;
1114 #ifdef INFLATE_STRICT 1116 strm->
msg = (
char *)
"invalid distance too far back";
1124 if (left == 0)
goto inf_leave;
1126 if (state->
offset > copy) {
1127 copy = state->
offset - copy;
1128 if (copy > state->
whave) {
1130 strm->
msg = (
char *)
"invalid distance too far back";
1134 #ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR 1135 Trace((stderr,
"inflate.c too far\n"));
1136 copy -= state->
whave;
1138 if (copy > left) copy = left;
1148 if (copy > state->
wnext) {
1149 copy -= state->
wnext;
1157 from = put - state->
offset;
1160 if (copy > left) copy = left;
1169 if (left == 0)
goto inf_leave;
1170 *put++ = (
unsigned char)(state->
length);
1179 state->
total += out;
1186 state->
flags ? hold :
1189 strm->
msg = (
char *)
"incorrect data check";
1194 Tracev((stderr,
"inflate: check matches trailer\n"));
1201 if (hold != (state->
total & 0xffffffffUL)) {
1202 strm->
msg = (
char *)
"incorrect length check";
1207 Tracev((stderr,
"inflate: length matches trailer\n"));
1242 state->
total += out;
1243 if (state->
wrap && out)
1249 if (((in == 0 && out == 0) || flush ==
Z_FINISH) && ret ==
Z_OK)
#define RESTORE()
Definition: inflate.c:470
#define Z_BLOCK
Definition: zlib.h:169
unsigned nlen
Definition: inflate.h:112
unsigned short val
Definition: inftrees.h:27
#define NEEDBITS(n)
Definition: inflate.c:499
int havedict
Definition: inflate.h:85
Bytef * next_in
Definition: zlib.h:86
void zmemcpy(Bytef *dest, const Bytef *source, uInt len)
Definition: zutil.c:152
unsigned wnext
Definition: inflate.h:95
unsigned ndist
Definition: inflate.h:113
unsigned long total
Definition: inflate.h:89
gz_headerp head
Definition: inflate.h:90
unsigned wsize
Definition: inflate.h:93
int sane
Definition: inflate.h:119
unsigned have
Definition: inflate.h:114
uInt avail_in
Definition: zlib.h:87
unsigned distbits
Definition: inflate.h:109
#define Z_NEED_DICT
Definition: zlib.h:175
unsigned extra
Definition: inflate.h:104
Definition: inftrees.h:57
code const FAR * distcode
Definition: inflate.h:107
int last
Definition: inflate.h:83
#define Tracev(x)
Definition: zutil.h:232
unsigned long check
Definition: inflate.h:88
char * msg
Definition: zlib.h:94
#define ZSWAP32(q)
Definition: zutil.h:250
unsigned char op
Definition: inftrees.h:25
#define Z_STREAM_ERROR
Definition: zlib.h:177
unsigned lenbits
Definition: inflate.h:108
unsigned short lens[320]
Definition: inflate.h:116
#define z_const
Definition: zconf.h:224
unsigned ncode
Definition: inflate.h:111
int inflate_table(codetype type, unsigned short FAR *lens, unsigned codes, code FAR *FAR *table, unsigned FAR *bits, unsigned short FAR *work)
Definition: inftrees.c:32
#define Z_FINISH
Definition: zlib.h:168
#define CRC2(check, word)
Definition: inflate.c:441
#define BYTEBITS()
Definition: inflate.c:517
#define LOAD()
Definition: inflate.c:459
code FAR * next
Definition: inflate.h:115
int data_type
Definition: zlib.h:101
code codes[ENOUGH]
Definition: inflate.h:118
unsigned long hold
Definition: inflate.h:98
Definition: inftrees.h:55
#define Z_DEFLATED
Definition: zlib.h:205
#define Z_DATA_ERROR
Definition: zlib.h:178
uLong total_in
Definition: zlib.h:88
#define Z_TREES
Definition: zlib.h:170
#define Z_STREAM_END
Definition: zlib.h:174
#define FAR
Definition: jmorecfg.h:215
unsigned long ZEXPORT crc32(unsigned long crc, const unsigned char FAR *buf, uInt len)
Definition: crc32.c:204
Bytef * next_out
Definition: zlib.h:90
#define BITS(n)
Definition: inflate.c:506
#define UPDATE(check, buf, len)
Definition: inflate.c:433
#define GUNZIP
Definition: inflate.h:16
unsigned short work[288]
Definition: inflate.h:117
#define Z_MEM_ERROR
Definition: zlib.h:179
unsigned char bits
Definition: inftrees.h:26
#define Trace(x)
Definition: zutil.h:231
Definition: inftrees.h:24
unsigned dmax
Definition: inflate.h:87
unsigned bits
Definition: inflate.h:99
uLong adler
Definition: zlib.h:102
uLong total_out
Definition: zlib.h:92
uLong ZEXPORT adler32(uLong adler, const Bytef *buf, uInt len)
Definition: adler32.c:65
#define INITBITS()
Definition: inflate.c:481
#define Z_BUF_ERROR
Definition: zlib.h:180
int back
Definition: inflate.h:120
unsigned char FAR * window
Definition: inflate.h:96
inflate_mode mode
Definition: inflate.h:82
uInt avail_out
Definition: zlib.h:91
#define Z_OK
Definition: zlib.h:173
Definition: inftrees.h:56
void inflate_fast(z_streamp strm, unsigned start)
Definition: inffast.c:67
static int updatewindow(z_streamp strm, const Bytef *end, unsigned copy)
Definition: inflate.c:379
struct internal_state * state
Definition: zlib.h:95
#define PULLBYTE()
Definition: inflate.c:489
#define CRC4(check, word)
Definition: inflate.c:448
#define Z_NULL
Definition: zlib.h:208
unsigned whave
Definition: inflate.h:94
unsigned offset
Definition: inflate.h:102
unsigned was
Definition: inflate.h:121
int flags
Definition: inflate.h:86
code const FAR * lencode
Definition: inflate.h:106
unsigned wbits
Definition: inflate.h:92
int wrap
Definition: inflate.h:84
#define DROPBITS(n)
Definition: inflate.c:510
#define Tracevv(x)
Definition: zutil.h:233
unsigned length
Definition: inflate.h:101
static void fixedtables(struct inflate_state FAR *state)
Definition: inflate.c:261