MCPcopy Create free account
hub / github.com/F-Stack/f-stack / cover_wrap

Function cover_wrap

freebsd/contrib/zlib/test/infcover.c:388–444  ·  view source on GitHub ↗

cover all inflate() header and trailer cases and code after inflate() */

Source from the content-addressed store, hash-verified

386
387/* cover all inflate() header and trailer cases and code after inflate() */
388local void cover_wrap(void)
389{
390 int ret;
391 z_stream strm, copy;
392 unsigned char dict[257];
393
394 ret = inflate(Z_NULL, 0); assert(ret == Z_STREAM_ERROR);
395 ret = inflateEnd(Z_NULL); assert(ret == Z_STREAM_ERROR);
396 ret = inflateCopy(Z_NULL, Z_NULL); assert(ret == Z_STREAM_ERROR);
397 fputs("inflate bad parameters\n", stderr);
398
399 inf("1f 8b 0 0", "bad gzip method", 0, 31, 0, Z_DATA_ERROR);
400 inf("1f 8b 8 80", "bad gzip flags", 0, 31, 0, Z_DATA_ERROR);
401 inf("77 85", "bad zlib method", 0, 15, 0, Z_DATA_ERROR);
402 inf("8 99", "set window size from header", 0, 0, 0, Z_OK);
403 inf("78 9c", "bad zlib window size", 0, 8, 0, Z_DATA_ERROR);
404 inf("78 9c 63 0 0 0 1 0 1", "check adler32", 0, 15, 1, Z_STREAM_END);
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,
406 Z_DATA_ERROR);
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",
408 0, 47, 0, Z_STREAM_END);
409 inf("78 90", "bad zlib header check", 0, 47, 0, Z_DATA_ERROR);
410 inf("8 b8 0 0 0 1", "need dictionary", 0, 8, 0, Z_NEED_DICT);
411 inf("78 9c 63 0", "compute adler32", 0, 15, 1, Z_OK);
412
413 mem_setup(&strm);
414 strm.avail_in = 0;
415 strm.next_in = Z_NULL;
416 ret = inflateInit2(&strm, -8);
417 strm.avail_in = 2;
418 strm.next_in = (void *)"\x63";
419 strm.avail_out = 1;
420 strm.next_out = (void *)&ret;
421 mem_limit(&strm, 1);
422 ret = inflate(&strm, Z_NO_FLUSH); assert(ret == Z_MEM_ERROR);
423 ret = inflate(&strm, Z_NO_FLUSH); assert(ret == Z_MEM_ERROR);
424 mem_limit(&strm, 0);
425 memset(dict, 0, 257);
426 ret = inflateSetDictionary(&strm, dict, 257);
427 assert(ret == Z_OK);
428 mem_limit(&strm, (sizeof(struct inflate_state) << 1) + 256);
429 ret = inflatePrime(&strm, 16, 0); assert(ret == Z_OK);
430 strm.avail_in = 2;
431 strm.next_in = (void *)"\x80";
432 ret = inflateSync(&strm); assert(ret == Z_DATA_ERROR);
433 ret = inflate(&strm, Z_NO_FLUSH); assert(ret == Z_STREAM_ERROR);
434 strm.avail_in = 4;
435 strm.next_in = (void *)"\0\0\xff\xff";
436 ret = inflateSync(&strm); assert(ret == Z_OK);
437 (void)inflateSyncPoint(&strm);
438 ret = inflateCopy(&copy, &strm); assert(ret == Z_MEM_ERROR);
439 mem_limit(&strm, 0);
440 ret = inflateUndermine(&strm, 1); assert(ret == Z_DATA_ERROR);
441 (void)inflateMark(&strm);
442 ret = inflateEnd(&strm); assert(ret == Z_OK);
443 mem_done(&strm, "miscellaneous, force memory errors");
444}
445

Callers 1

mainFunction · 0.85

Calls 6

infFunction · 0.85
mem_setupFunction · 0.85
mem_limitFunction · 0.85
memsetFunction · 0.85
inflatePrimeFunction · 0.85
mem_doneFunction · 0.85

Tested by

no test coverage detected