76 size_t len = count * (size_t)size;
87 memset(ptr, 0xa5, len);
127 if (next->
ptr == ptr)
133 }
while (next != NULL && next->
ptr != ptr);
163 assert(zone != NULL);
188 fprintf(stderr,
"%s: %lu allocated\n", prefix, zone->
total);
196 fprintf(stderr,
"%s: %lu high water mark\n", prefix, zone->
highwater);
211 while (item != NULL) {
220 if (count || zone->
total)
221 fprintf(stderr,
"** %s: %lu bytes in %d blocks not freed\n",
222 prefix, zone->
total, count);
224 fprintf(stderr,
"** %s: %d frees not LIFO\n", prefix, zone->
notlifo);
226 fprintf(stderr,
"** %s: %d frees not recognized\n",
227 prefix, zone->
rogue);
245 local unsigned char *
h2b(
const char *hex,
unsigned *len)
250 in =
malloc((strlen(hex) + 1) >> 1);
256 if (*hex >=
'0' && *hex <=
'9')
257 val = (val << 4) + *hex -
'0';
258 else if (*hex >=
'A' && *hex <=
'F')
259 val = (val << 4) + *hex -
'A' + 10;
260 else if (*hex >=
'a' && *hex <=
'f')
261 val = (val << 4) + *hex -
'a' + 10;
262 else if (val != 1 && val < 32)
265 in[next++] = val & 0xff;
271 in = reallocf(in, next);
284 local void inf(
char *hex,
char *what,
unsigned step,
int win,
unsigned len,
289 unsigned char *
in, *
out;
301 out =
malloc(len); assert(out != NULL);
311 in =
h2b(hex, &have); assert(in != NULL);
312 if (step == 0 || step > have)
339 strm.
avail_in = step > have ? have : step;
367 inf(
"63 0",
"force window allocation", 0, -15, 1,
Z_OK);
368 inf(
"63 18 5",
"force window replacement", 0, -8, 259,
Z_OK);
369 inf(
"63 18 68 30 d0 0 0",
"force split window update", 4, -8, 259,
Z_OK);
384 fputs(
"inflate built-in memory routines\n", stderr);
392 unsigned char dict[257];
397 fputs(
"inflate bad parameters\n", stderr);
402 inf(
"8 99",
"set window size from header", 0, 0, 0,
Z_OK);
405 inf(
"1f 8b 8 1e 0 0 0 0 0 0 1 0 0 0 0 0 0",
"bad header crc", 0, 47, 1,
407 inf(
"1f 8b 8 2 0 0 0 0 0 0 1d 26 3 0 0 0 0 0 0 0 0 0",
"check gzip length",
411 inf(
"78 9c 63 0",
"compute adler32", 0, 15, 1,
Z_OK);
425 memset(dict, 0, 257);
435 strm.
next_in = (
void *)
"\0\0\xff\xff";
443 mem_done(&strm,
"miscellaneous, force memory errors");
449 static unsigned int next = 0;
450 static unsigned char dat[] = {0x63, 0, 2, 0};
457 state = (
void *)((
z_stream *)desc)->state;
460 return next <
sizeof(dat) ? (*buf = dat + next++, 1) : 0;
463 local int push(
void *desc,
unsigned char *buf,
unsigned len)
474 unsigned char win[32768];
482 fputs(
"inflateBack bad parameters\n", stderr);
492 strm.
next_in = (
void *)
"\x63\x00";
499 mem_done(&strm,
"inflateBack bad state");
503 fputs(
"inflateBack built-in memory routines\n", stderr);
507 local int try(
char *hex,
char *
id,
int err)
511 unsigned char *
in, *
out, *win;
525 prefix =
malloc(strlen(
id) + 6);
526 assert(prefix != NULL);
530 strcat(prefix,
"-late");
548 assert(strcmp(
id, strm.
msg) == 0);
556 strcat(prefix,
"-back");
566 assert(strcmp(
id, strm.
msg) == 0);
583 try(
"0 0 0 0 0",
"invalid stored block lengths", 1);
584 try(
"3 0",
"fixed", 0);
585 try(
"6",
"invalid block type", 1);
586 try(
"1 1 0 fe ff 0",
"stored", 0);
587 try(
"fc 0 0",
"too many length or distance symbols", 1);
588 try(
"4 0 fe ff",
"invalid code lengths set", 1);
589 try(
"4 0 24 49 0",
"invalid bit length repeat", 1);
590 try(
"4 0 24 e9 ff ff",
"invalid bit length repeat", 1);
591 try(
"4 0 24 e9 ff 6d",
"invalid code -- missing end-of-block", 1);
592 try(
"4 80 49 92 24 49 92 24 71 ff ff 93 11 0",
593 "invalid literal/lengths set", 1);
594 try(
"4 80 49 92 24 49 92 24 f b4 ff ff c3 84",
"invalid distances set", 1);
595 try(
"4 c0 81 8 0 0 0 0 20 7f eb b 0 0",
"invalid literal/length code", 1);
596 try(
"2 7e ff ff",
"invalid distance code", 1);
597 try(
"c c0 81 0 0 0 0 0 90 ff 6b 4 0",
"invalid distance too far back", 1);
600 try(
"1f 8b 8 0 0 0 0 0 0 0 3 0 0 0 0 1",
"incorrect data check", -1);
601 try(
"1f 8b 8 0 0 0 0 0 0 0 3 0 0 0 0 0 0 0 0 1",
602 "incorrect length check", -1);
603 try(
"5 c0 21 d 0 0 0 80 b0 fe 6d 2f 91 6c",
"pull 17", 0);
604 try(
"5 e0 81 91 24 cb b2 2c 49 e2 f 2e 8b 9a 47 56 9f fb fe ec d2 ff 1f",
606 try(
"ed c0 1 1 0 0 0 40 20 ff 57 1b 42 2c 4f",
"length extra", 0);
607 try(
"ed cf c1 b1 2c 47 10 c4 30 fa 6f 35 1d 1 82 59 3d fb be 2e 2a fc f c",
608 "long distance and extra", 0);
609 try(
"ed c0 81 0 0 0 0 80 a0 fd a9 17 a9 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 " 610 "0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6",
"window end", 0);
611 inf(
"2 8 20 80 0 3 0",
"inflate_fast TYPE return", 0, -15, 258,
613 inf(
"63 18 5 40 c 0",
"window wrap", 3, -8, 300,
Z_OK);
626 for (bits = 0; bits < 15; bits++)
627 lens[bits] = (
unsigned short)(bits + 1);
637 fputs(
"inflate_table not enough errors\n", stderr);
643 inf(
"e5 e0 81 ad 6d cb b2 2c c9 01 1e 59 63 ae 7d ee fb 4d fd b5 35 41 68" 644 " ff 7f 0f 0 0 0",
"fast length extra bits", 0, -8, 258,
Z_DATA_ERROR);
645 inf(
"25 fd 81 b5 6d 59 b6 6a 49 ea af 35 6 34 eb 8c b9 f6 b9 1e ef 67 49" 646 " 50 fe ff ff 3f 0 0",
"fast distance extra bits", 0, -8, 258,
648 inf(
"3 7e 0 0 0 0 0",
"fast invalid distance code", 0, -8, 258,
650 inf(
"1b 7 0 0 0 0 0",
"fast invalid literal/length code", 0, -8, 258,
652 inf(
"d c7 1 ae eb 38 c 4 41 a0 87 72 de df fb 1f b8 36 b1 38 5d ff ff 0",
653 "fast 2nd level codes and too far back", 0, -8, 258,
Z_DATA_ERROR);
654 inf(
"63 18 5 8c 10 8 0 0 0 0",
"very common case", 0, -8, 259,
Z_OK);
655 inf(
"63 60 60 18 c9 0 8 18 18 18 26 c0 28 0 29 0 0 0",
656 "contiguous and wrap around window", 6, -8, 259,
Z_OK);
657 inf(
"63 0 3 0 0 0 0 0",
"copy direct from output", 0, -8, 259,
static int push(void *desc, unsigned char *buf, unsigned len)
static void cover_back(void)
int inflateUndermine(z_streamp strm, int subvert)
int inflate_table(codetype type, unsigned short *lens, unsigned codes, code * *table, unsigned *bits, unsigned short *work)
static void cover_trees(void)
int inflateGetHeader(z_streamp strm, gz_headerp head)
int inflateReset2(z_streamp strm, int windowBits)
static void cover_inflate(void)
unsigned short prefix[65536]
int inflateCopy(z_streamp dest, z_streamp source)
static unsigned pull(void *desc, unsigned char **buf)
static void * mem_alloc(void *mem, unsigned count, unsigned size)
static void cover_wrap(void)
#define inflateInit2(strm, windowBits)
int inflateBackInit_(z_streamp strm, int windowBits, unsigned char *window, char *version, int stream_size)
static unsigned char * h2b(const char *hex, unsigned *len)
static int out(void *out_desc, unsigned char *buf, unsigned len)
static void inf(char *hex, char *what, unsigned step, int win, unsigned len, int err)
static void mem_high(z_stream *strm, char *prefix)
int inflateBack(z_streamp strm, in_func in, void *in_desc, out_func out, void *out_desc)
static void cover_support(void)
long inflateMark(z_streamp strm)
int inflateSetDictionary(z_streamp strm, Bytef *dictionary, uInt dictLength)
int inflateBackEnd(z_streamp strm)
int inflatePrime(z_streamp strm, int bits, int value)
int inflateSync(z_streamp strm)
int inflateInit_(z_streamp strm, char *version, int stream_size)
static unsigned in(void *in_desc, z_const unsigned char **buf)
#define inflateInit(strm)
static int bits(struct state *s, int need)
int inflateEnd(z_streamp strm)
int inflate(z_streamp strm, int flush)
struct internal_state * state
static void mem_free(void *mem, void *ptr)
int inflateSyncPoint(z_streamp strm)
static void mem_setup(z_stream *strm)
static void mem_limit(z_stream *strm, size_t limit)
#define inflateBackInit(strm, windowBits, window)
static void cover_fast(void)
static void mem_used(z_stream *strm, char *prefix)
static void mem_done(z_stream *strm, char *prefix)
static big_t count(int syms, int len, int left)