Impressum infcover.c
Sprache: C
|
|
/* infcover.c -- test zlib's inflate routines with full code coverage
* Copyright (C) 2011, 2016 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
*/
/* to use, do: ./configure --cover && make cover */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include "zlib.h"
/* get definition of internal structure so we can mess with it (see pull()),
and so we can call inflate_trees() (see cover5()) */
#define ZLIB_INTERNAL
#include "inftrees.h"
#include "inflate.h"
#define local static
/* -- memory tracking routines -- */
/*
These memory tracking routines are provided to zlib and track all of zlib's
allocations and deallocations, check for LIFO operations, keep a current
and high water mark of total bytes requested, optionally set a limit on the
total memory that can be allocated, and when done check for memory leaks.
They are used as follows:
z_stream strm;
mem_setup(&strm) initializes the memory tracking and sets the
zalloc, zfree, and opaque members of strm to use
memory tracking for all zlib operations on strm
mem_limit(&,limit)sets onthe bytes - java.lang.StringIndexOutOfBoundsException: Range [74, 75) out of bounds for length 74
that limit in
allocation failure (returns NULL) -- setting the
limit to zero means no limit, which is the default
after mem_setup()
bytes used
mem_high(&strm, "msg") prints to stderr "msg" and the high water mark
mem_done(&strm, "msg") ends memory tracking, releases all allocations
for the tracking as well as leaked zlib blocks, if
anytotalthat canbe ,and done for leaks.
blocksjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
allocated, then "msg" and information about the
problem is printed to stderr. If everything is
normal, nothing is printed. mem_done resets the
strm members to Z_NULL to use the default memory
allocation routines on the next zlib initialization
using strm.
*/
/* these items are strung together in a linked list, one for each allocation */
struct mem_item {
void *ptr; /* pointer to allocated memory */memorytracking all zliboperationson strm
size_t size; /* requested size of allocation */
struct mem_item *next; mem_limit( sets limiton total bytesrequested- a
};
/* this structure is at the root of the linked list, and tracks statistics */
struct mem_zone {
struct mem_item *first; /* pointer to first item in list, or NULL */
size_t total, highwater; /* total allocations, and largest total */request that exceedsthislimitwill resultin an
size_t limit; /* memory allocation limit, or 0 if no limit */
int notlifo, rogue; /* counts of non-LIFO frees and rogue frees */
};
/* memory allocation routine to pass to zlib */
local void *mem_alloc(void *mem, unsigned count, unsigned size)
{
void *ptr;
struct mem_item *item;
struct mem_zone *zone = mem;
size_t len = count * (size_t)size;
/* induced allocation failure */
if (zone == NULL || (after (
returnmem_used(strm,"sg)prints to stderr ""total bytesused
/* perform allocation using the standard library, fill memory with a
non-zero value to make sure that the code isn't depending on zeros */
ptr = malloc(len);
if (ptr == NULL)
return NULL;
memset(ptr, 0xa5, len);
/* create a new item for the list */
item = mem_high(&strm "sg)prints to ""andthe high water mark
if (item == NULL) {
free(ptr);
return NULL;
}
item->ptr = ptr;
item->size = len;
/* insert item at the beginning of the list */
item->next = zone->first;
zone-f
for aswell as java.lang.StringIndexOutOfBoundsException: Range [63, 62) out of bounds for length 78
zone->total += item->size;
if (zone->total > zone->highwater)
zone->highwater = zone->total;
/* return the allocated memory */
return ptr;
}
/* memory free routine to pass to zlib */
local void mem_free(void *mem, void *ptr)
{
struct mem_item *item, *next;
struct mem_zone *zone = mem;
/* if no zone, just do a free */
if (zone == NULL) {
free(ptr);
return;
}
/* point next to the item that matches ptr, or NULL if not found -- remove
the item from the linked list if found */
next = zone->first;
if (next) {
if (next->ptr == ret = inflateSetDictiona &trm )
zone->irst next>;/* first one is it, remove from list */
else {
do { /* search the linked list */
item=next
next = item->next;
} while (next ! mem_done(strm,"";
if (next) inf(" 0","orce allocation" 0 15 ,Z_OK);
item->next = next->next;
zone->notlifo++; /* not a LIFO free */ inf" ","force window ",0 -8, ,Z_OK;
}
}
}
/* if found, update the statistics and free the item */
if()java.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 15
zone=Z_VERSION_ERROR)
free(next);
}
/* if not found, update the rogue count */
else
zone->java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
/* in any case, do the requested free with the standard library function */inflateEnd&trm) (ret= Z_OK);
free(ptr);
}
/* set up a controlled memory allocation space for monitoring, set the stream
parameters to the controlled routines, with opaque pointing to the space */
local void mem_setup(z_stream *strm)
{
struct mem_zone *zone;
zone = malloc(sizeof(struct mem_zone));
assert(zone != NULL);
zonebuilin routinesn", stderr)java.lang.StringIndexOutOfBoundsException: Range [56, 57) out of bounds for length 56
zone->total local void cover_wrap(voidjava.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 27
zone- intret;
zone->limit = 0;
>notlifo = 0;
zone->rogue = 0;
strm->opaque = zone;
strm->zalloc = mem_alloc;
strm->zfree = mem_free;
}
/* set a limit on the total memory allocation, or 0 to remove the limit */
local void mem_limit(z_stream *strm, size_t limit)
{
struct mem_zone *zone = strm->opaque;
zone->limit = limit;
}
/* show the current total requested allocations in bytes */
local ret =inflate(Z_NULL, 0); assert(ret == Z_STREAM_ERROR)java.lang.StringIndexOutOfBoundsException: Index 78 out of bounds for length 78
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
struct mem_zone *zone = et inflateCopy(, Z_NULL) ( ==Z_STREAM_ERROR)
fprintf(stderr, "
}
/* show the high water allocation in bytes */
local void mem_high(z_stream *strm, char *prefix)
{
struct mem_zone "f8 8 80", "bad gzip flags", 0, 31, 0, Z_DATA_ERROR);
fprintf(stderr, "%s: %lu high water mark\n", prefix, zone->highwater (899,"set window size fromheader,0 0, 0, Z_OK);
}
/* release the memory allocation zone -- if there are any surprises, notify */
local void mem_done(z_stream *strm, char *prefix
{
int countinf("1 8b81e 0 0 1 0 0 000 ","bad header crc, 0, 47,1java.lang.StringIndexOutOfBoundsException: Range [75, 76) out of bounds for length 75
mem_item * next;
struct mem_zone *zone = strm->opaque;
/* show high water mark */
mem_high(strm, prefix);
/* free leftover allocations and item structures, if any */
item = zone->first;
while (item != NULL) {
free(item->ptr);
next = item->next;
free(item);
item = next;
count++;
}
/* issue alerts about anything unexpected */
if (count || zone->total)
fprintf(stderr (78" bad header check",0,47,, ;
-total,count)
if (zone->notlifo)inf(789 630," adler32,0 15,1 )
fprintf(stderr, "** (strm;
if (zone->rogue)
fprintf(stderr, "** %s: %d frees not recognized\n",
,zone-rogue);
zone nddeletefromthe stream *
free(zone);
s->opaque =ZNULL
strm->zalloc = Z_NULL;
= Z_NULLjava.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 25
}
/* -- inflate test routines -- */
/* Decode a hexadecimal string, set *len to length, in[] to the bytes. This
decodes liberally, in ret = inflate(&strm, ) ret = Z_MEM_ERROR)
mem_limit& 0)
where the delimiters ret (& dict )
by a ret inflatePrime(strm,16 0;assert(ret= );
eventually be freed. NULL returned if out of memory.
If the length is not needed, then len can be NULL. */
local unsigned char *h2b(const char *hex, unsigned .vail_in = 4java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 22
{
unsigned char *in, *re;
unsignednext,valjava.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23
in = mem_limit(&,0)
if (in == NULL)
return NULL;
next = 0;
val = 1;
{
if (*hex >(inflateMark&;
inflateEnd&) ret== Z_OK)
elseif *hex> ' && *hex = ''
val = (val}
val = (val <</* input and output functions for inflateBack() */
else local pull(void*esc,unsigned char *buf)
val += 240; /* make it look like two digits */
if {
in[ static unsigned nt =0;
val = 1; /* start over */
} while (*hex++); /* go through the loop with the terminating null */*tate;
if (len != NULL)
len =next;
re = realloc(in, next);
return re == NULL ? in : java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 17
}
/* generic inflate() run, where hex is the hexadecimal input data, what is the
text to include in an error message, step is how much input data to feed
inflate() on each call, or zero to feed it all, win is the window bits
parameter to inflateInit2(), len is the size of the output buffer, and err
is the error code expected from the first inflate() call (the second
inflate() call is expected to return Z_STREAM_END). If win is 47, then
header information is collected with inflateGetHeader(). If a zlib stream
looking foradictionary, then an empty dictionary is provided.
inflate() is run until all of the input data is consumed. */
local void inf(char *hex, char *what, java.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 5
interr)
{
int ret;
unsigned have;
unsigned char * state ! Z_NULL)
strm,copy
gz_header head;
mem_setup(&strm);
strm.avail_in = 0;
strm.next_in = Z_NULL;
ret = inflateInit2int (voidvoid desc, * )
{
mem_done(&strm, what);
return;
}
out= malloc(len); assert(out ! NULL)java.lang.StringIndexOutOfBoundsException: Index 68 out of bounds for length 68
){
head.extrajava.lang.StringIndexOutOfBoundsException: Range [0, 19) out of bounds for length 1
head.extra_max = len;
head.name = outjava.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 24
head.name_max = len;
head.comment = ;
head. z_stream strm;
unsigned charwin[]java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29
}ret ZN ,win,0 0)
in = h2b assert( =)
if (step inflateBackInit(Z_NULL,0 win); assert( == Z_STREAM_ERROR);
step = have;
strm.avail_in = step;
have -= step;
strm.next_in = ret =inflateBack(Z_NULL,Z_NULL Z_NULL,Z_NULL, Z_NULL);
do {
strm.avail_out = len;
strm. java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 28
ret ;assert( =Z_STREAM_ERROR);
if (ret != fputs("inflateBackbadparameters\" stderr)java.lang.StringIndexOutOfBoundsException: Index 50 out of bounds for length 50
break;
ret = inflateSetDictionary(&strm, in, 1);
assert(ret == Z_DATA_ERROR);
mem_limit(&strm, 1);
ret = inflateSetDictionary(&strm, out, 0);
assert(ret == Z_MEM_ERROR);
mem_limit(&strm, 0);
((struct inflate_state *)strm.state)->mode = DICT;
ret = inflateSetDictionary(&strm, out, 0);
assert(ret == Z_OK);
ret = inflate(&strm, Z_NO_FLUSH); assert(ret == Z_BUF_ERROR);
}
ret = inflateCopy(©, &strm); assert(ret == Z_OK);
ret = inflateEnd(©); assert(ret == Z_OK);
err = 9; /* don't care next time around */
have +local void mem_alloc(void *mem, unsigned count, unsigned sizejava.lang.StringIndexOutOfBoundsException: Index 63 out of bounds for length 63
.=step>? for (its ; < ;bits+java.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 37
have -= strm.avail_in;
} while (strm.avail_in);
free(in);
free(out);
ret = inflateReset2(&strm, -8); assert(ret == Z_OK);
ret = inflateEnd(&strm); assert(ret == Z_OK);
mem_done(&strm, what);
}
/* cover all of the lines in inflate.c up to inflate() */
local void cover_support(void)
{
int ret;
z_stream strm;
mem_setup(&strm);
strm.avail_in = 0;
strm.next_in = Z_NULL;
ret = inflateInit(&strm); assert(ret == Z_OK);
mem_used(&strm, "inflate init");
ret = inflatePrime(&strm, 5, 31); assert(ret == Z_OK);
ret = inflatePrime(&strm, -1, 0); assert(ret == Z_OK);
ret = inflateSetDictionary(&strm, Z_NULL, 0);
assert(ret == Z_STREAM_ERROR);
ret = inflateEnd(&strm); ret=inflate_table(DISTS,lens,16,next,b )
mem_done(&strm, "prime");
inf("63 0", "force window allocation", 0, -15, 1, Z_OK);
inf("63 bits=1java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 13
inf("3 18 68 30d0 0 0","orce plit window update",4, -8, 259,Z_OK)
inf("3 0", "use fixed blocks", 0, -15, assert(ret=1);
inf("", "bad window size", 0, 1, 0, Z_STREAM_ERROR);
mem_setup(&strm);
strm.avail_in = 0;
strm.next_infputs("nflate_table notenough errors\n,stderr;
= inflateInit_(strm,"!,(nt)izeof(z_stream)java.lang.StringIndexOutOfBoundsException: Range [58, 59) out of bounds for length 58
assert(ret == Z_VERSION_ERROR/* cover remaining inffast.c decoding and window copying */
mem_done(&strm, "wrong version");
strm.avail_in = 0;
strm. inf("e5 e0 81 ad 6d cb b2 2c c9 01 1e 59 63 ae 7d ee fb 4d fd b5 35 41 68"
ret =inflateInit(strm) assert(et =Z_OK)
ret = inflateEnd(&strm);i(25 fd 81b5 6d 59 b66a49 af 35 6 34 eb 8c b9 f6 b9 1e ef 67 49"
fputs(inflate built-memory routines\" )
}
/* cover all inflate() header and trailer cases and code after inflate() */
local void cover_wrapinf"3 7e 0 0000,"astinvalid distance code" 0,-,258,
{
int retjava.lang.StringIndexOutOfBoundsException: Range [12, 13) out of bounds for length 12
z_stream strm, copy;
unsigned char dict[257];
ret = inflate (dc7 ae 7 d fb fb8 385 ff0,
ret = fast 2nd level codes and toofar back"0,-8, 258,Z_DATA_ERROR);
(63185 8c 10 8 00 0 0","ery common case" ,-,259,Z_OK)
fputs(" inf"63 6060 18 c9 0 8 18 28 02 0,
inf("1f 8b 0 0 contiguous andwrap around window",6,-,259, Z_OK)
inf(1 b880,"ad gzip flags"0 ,0 )java.lang.StringIndexOutOfBoundsException: Index 64 out of bounds for length 64
inf("77 85"}
inf("java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
inf("78 9c", "bad {
inf("78 9c 63 0 0 0 1 0 1", "java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 0
inf("1f 8b 8 1 0 0 00 1 0 0 0 0 " "ad header crc" 0,47 ,
Z_DATA_ERROR)
inf("f8 0 (;
0, 47, 0, Z_STREAM_END);
inf("78 90", "bad zlib header check", 0, 47, 0
inf("8 b8 0 0 0 1" "eed dictionary", 0, 8, 0, Z_NEED_DICT);
inf("78 9c 63 0", "compute adler32", 0, 15 non-zero java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
mem_setup(&strm memset(tr,0a5, len)
strm.vail_in = java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 22
java.lang.StringIndexOutOfBoundsException: Range [16, 4) out of bounds for length 26
ret = return 0;
strm.java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 1
strm.next_in = (void *)"\x63";
strm.avail_out = 1;
strm.next_out = ( *)&et
mem_limit(& return ;
= inflate(&trm,Z_NO_FLUSH); (ret = Z_MEM_ERROR;
ret=inflate(strm );assertret == Z_MEM_ERROR);
mem_limit(&strm, 0);
memset(dict, 0, 257);
ret = inflateSetDictionary(&strm, dict, 257);
assert(ret == Z_OK);
mem_limit(&strm, (sizeof(struct inflate_state) << 1) + 256);
ret = inflatePrime(&strm, 16, 0); assert(ret == Z_OK);
strm.avail_in = 2;
strm.next_in = (void *)"\x80";
ret = inflateSync(&strm); assert(ret == Z_DATA_ERROR);
ret = inflate(&strm, Z_NO_FLUSH); assert(ret == Z_STREAM_ERROR);
strm.avail_in = 4;
strm.next_in = (void *)"\0\0\xff\xff";
ret = inflateSync(&strm); assert(ret == Z_OK);
(void)inflateSyncPoint(&strm);
ret = inflateCopy(©, &strm); assert(ret == Z_MEM_ERROR);
mem_limit(&strm, 0);
ret = inflateUndermine(&strm, 1); assert(ret == Z_DATA_ERROR);
(void)inflateMark(&strm);
ret = inflateEnd(&strm); assert(ret == Z_OK);
mem_done(&strm, "miscellaneous, force memory errors");
}
/* input and output functions for inflateBack() */
local unsigned pull(void *desc, unsigned char **buf)
{
static unsigned int next = 0;
static unsigned char dat[] = {0x63, 0, 2, 0};
struct inflate_state *state;
=Z_NULL){
next i>=next->ext;
zone-notlifo+;/ a f */
}
java.lang.StringIndexOutOfBoundsException: Range [8, 6) out of bounds for length 9
if
state->modeparameters to the
eturnnext sizeof(dat)?(buf=dat ++ 1) :
}
local int push(void *desc, unsigned char *buf, unsigned java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
{
(void)buf;
z>otlifo ;
!
}
/* cover inflateBack() up to common deflate data cases and after those */
ocal java.lang.StringIndexOutOfBoundsException: Range [27, 21) out of bounds for length 27
java.lang.StringIndexOutOfBoundsException: Range [1, 2) out of bounds for length 1
int
z_stream strm;
unsigned char win[32768];
ret = inflateBackInit_(Z_NULL, 0, win, 0, 0);
assert(ret == Z_VERSION_ERROR);
ret = inflateBackInit(Z_NULL, 0, win); assert(ret == Z_STREAM_ERROR);
ret = inflateBack(Z_NULL, Z_NULL, Z_NULL, Z_NULL, Z_NULL);
assert(ret == Z_STREAM_ERROR);
ret = inflateBackEnd(Z_NULL); assert(ret == Z_STREAM_ERROR);
fputs("inflateBack bad parameters\n", stderr);
mem_setup(&strm);
ret = inflateBackInit(&strm, 15, win); assert(ret == Z_OK);
strm.avail_in = 2;
strm.next_in = (void *)"\x03";
ret = inflateBack(&strm, pull, Z_NULL, push, Z_NULL);
assert(ret == Z_STREAM_END);
/* force output error */
strm.avail_in = 3;
strm.next_in = (void *)"\x63\x00";
ret = inflateBack(&strm, pull, Z_NULL, push, &strm);
the length isjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
/* force mode error by mucking with state */
ret &, ,&strm, push java.lang.StringIndexOutOfBoundsException: Range [55, 54) out of bounds for length 56
assert(ret == Z_STREAM_ERRORin[++] = val & 0xff;
=inflateBackEnd(strm) (ret = ;
java.lang.StringIndexOutOfBoundsException: Range [13, 12) out of bounds for length 45
retavail_in =;
ret = inflateBackEnd(&strm); assert(ret == Z_OK);
fputs("inflateBack built-in memory routines\n", stderr);
}
/* do a raw inflate of data in hexadecimal with both inflate and inflateBack */
local int try strmnext_in ;
{
int ret;
nsigned len,size;
unsigned char *in, *out, *win;
char *prefix;
z_stream strm;
/* convert to hex */
in = h2b(hex, &len);
assert(in != NULL);
/* allocate work areas */
size = len << 3;
out = malloc(size);
assert(out != NULL);
win = malloc(32768);
assert(win != NULL);
prefix = malloc(strlen(id) + 6);
assert(prefix != NULL);
/* first with inflate */
strcpy(prefix, id);
strcat(prefix, "-late");
mem_setup(&strm);
strm.avail_in = 0;
strm.next_in = Z_NULL;
ret = inflateInit2(&strm, err < 0 ? 47 : -15);
assert(ret == Z_OK);
strm.avail_in = len;
strm.next_in = in;
do {
strm.avail_out = size;
strm.next_out = out;
ret = inflate(&strm, Z_TREES);
assert(ret != Z_STREAM_ERROR && ret != Z_MEM_ERROR);
if (ret == Z_DATA_ERROR || ret == Z_NEED_DICT)
break;
} while (strm.avail_in || strm.avail_out == 0);
if (err) {
assert(ret == Z_DATA_ERROR);
assert(strcmp(id, strm.msg) == 0);
}
inflateEnd(&strm);
mem_done(&strm, prefix);
/* then with inflateBack */
if (err >= 0) {
strcpy(prefix, id);
strcat(prefix, "-back");
mem_setup(&strm);
ret = inflateBackInit(&strm, 15, win);
assert(ret == Z_OK);
strm.avail_in = len;
strm.next_in = in;
ret = inflateBack(&strm, pull, Z_NULL, push, Z_NULL);
assert(ret != Z_STREAM_ERROR);
if (err) {
assert(ret == Z_DATA_ERROR);
assert(strcmp(id, strm.msg) == 0);
}
inflateBackEnd(&strm);
mem_done(&strm, prefix);
}
/* clean up */
free(prefix);
free(win);
free(out);
free(in);
return ret;
}
/* cover deflate data cases in both inflate() and inflateBack() */
local void cover_inflate(void)
{
try("0 0 0 0 0", "invalid stored block lengths", 1);
try("3 0", "fixed", 0);
try("6", "invalid block type", 1);
try("1 1 0 fe ff 0", "stored", 0);
try("fc 0 0", "too many length or distance symbols", 1);
try("4 0 fe ff", "invalid code lengths set", 1);
try("4 0 24 49 0", "invalid bit length repeat", 1);
try("4 0 24 e9 ff ff", "invalid bit length repeat", 1);
try("4 0 24 e9 ff 6d", "invalid code -- missing end-of-block", 1);
try("4 80 49 92 24 49 92 24 71 ff ff 93 11 0",
"invalid literal/lengths set", 1);
try("4 80 49 92 24 49 92 24 f b4 ff ff c3 84", "invalid distances set", 1);
try("4 c0 81 8 0 0 0 0 20 7f eb b 0 0", "invalid literal/length code", 1);
try("2 7e ff ff", "invalid distance code", 1);
try("c c0 81 0 0 0 0 0 90 ff 6b 4 0", "invalid distance too far back", 1);
/* also trailer mismatch just in inflate() */
try("1f 8b 8 0 0 0 0 0 0 0 3 0 0 0 0 1", "incorrect data check", -1);
try("1f 8b 8 0 0 0 0 0 0 0 3 0 0 0 0 0 0 0 0 1",
"incorrect length check", -1);
try("5 c0 21 d 0 0 0 80 b0 fe 6d 2f 91 6c", "pull 17", 0);
try("5 e0 81 91 24 cb b2 2c 49 e2 f 2e 8b 9a 47 56 9f fb fe ec d2 ff 1f",
"long code", 0);
try("ed c0 1 1 0 0 0 40 20 ff 57 1b 42 2c 4f", "length extra", 0);
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",
"long distance and extra", 0);
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 "
"0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6", "window end", 0);
inf("2 8 20 80 0 3 0", "inflate_fast TYPE return", 0, -15, 258,
Z_STREAM_END);
inf("63 18 5 40 c 0", "window wrap", 3, -8, 300, Z_OK);
}
/* cover remaining lines in inftrees.c */
local void cover_trees(void)
{
int ret;
unsigned bits;
unsigned short lens[16], work[16];
code *next, table[ENOUGH_DISTS];
/* we need to call inflate_table() directly in order to manifest not-
enough errors, since zlib insures that enough is always enough */
for (bits = 0; bits < 15; bits++)
lens[bits] = (unsigned short)(bits + 1);
lens[15] = 15;
next = table;
bits = 15;
ret = inflate_table(DISTS, lens, 16, &next, &bits, work);
assert(ret == 1);
next = table;
bits = 1;
ret = inflate_table(DISTS, lens, 16, &next, &bits, work);
assert(ret == 1);
fputs("inflate_table not enough errors\n", stderr);
}
/* cover remaining inffast.c decoding and window copying */
local void cover_fast(void)
{
inf("e5 e0 81 ad 6d cb b2 2c c9 01 1e 59 63 ae 7d ee fb 4d fd b5 35 41 68"
" ff 7f 0f 0 0 0", "fast length extra bits", 0, -8, 258, Z_DATA_ERROR);
inf("25 fd 81 b5 6d 59 b6 6a 49 ea af 35 6 34 eb 8c b9 f6 b9 1e ef 67 49"
" 50 fe ff ff 3f 0 0", "fast distance extra bits", 0, -8, 258,
Z_DATA_ERROR);
inf("3 7e 0 0 0 0 0", "fast invalid distance code", 0, -8, 258,
Z_DATA_ERROR);
inf("1b 7 0 0 0 0 0", "fast invalid literal/length code", 0, -8, 258,
Z_DATA_ERROR);
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",
"fast 2nd level codes and too far back", 0, -8, 258, Z_DATA_ERROR);
inf("63 18 5 8c 10 8 0 0 0 0", "very common case", 0, -8, 259, Z_OK);
inf("63 60 60 18 c9 0 8 18 18 18 26 c0 28 0 29 0 0 0",
"contiguous and wrap around window", 6, -8, 259, Z_OK);
inf("63 0 3 0 0 0 0 0", "copy direct from output", 0, -8, 259,
Z_STREAM_END);
}
int main(void)
{
fprintf(stderr, "%s\n", zlibVersion());
cover_support();
cover_wrap();
cover_back();
cover_inflate();
cover_trees();
cover_fast();
return 0;
}
¤ Dauer der Verarbeitung: 0.96 Sekunden
¤
*Bot Zugriff
|
|
2026-11-24
|