summaryrefslogtreecommitdiff
path: root/test/example.c
AgeCommit message (Collapse)Author
2021-12-24IBM Z: Do not check inflateGetDictionary() with DFLTCCIlya Leoshkevich
The zlib manual does not specify a strict contract for inflateGetDictionary(), it merely says that it "Returns the sliding dictionary being maintained by inflate", which is an implementation detail. IBM Z inflate's behavior differs from that of software, and may change in the future to boot.
2021-12-24Use helper function for printing error and exiting in example.Nathan Moinvaziri
2021-12-24Fill out gzheader before calling deflateSetHeader for better code coverage ↵Nathan Moinvaziri
in example.
2021-12-24Added code coverage for inflateGetDictionary in example.Nathan Moinvaziri
2021-12-24Call deflateBound to calculate length with custom gzip header in example.Nathan Moinvaziri
2021-06-21Added Z_UNUSED define for ignore unused variables.Nathan Moinvaziri
2020-10-09Fixed dereference of possibly null head variable in test_deflate_set_header.Nathan Moinvaziri
example.c:920:16: warning: dereference of possibly-NULL ‘head’ [CWE-690] [-Wanalyzer-possible-null-dereference] 920 | head->text = 1; | ~~~~~~~~~~~^~~ ‘test_deflate_set_header’: event 1 | | 906 | PREFIX(gz_header) *head = calloc(1, sizeof(PREFIX(gz_header))); | | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | | | | | (1) this call could return NULL
2020-08-23Reintroduce support for ZLIB_CONST in compat mode. (#704)Mika Lindqvist
* Reintroduce support for ZLIB_CONST in compat mode.
2020-08-20Fix testsuite warnings on Windows, using PRIu64Josh Triplett
zlib-ng already counts on inttypes.h and stdint.h, so use those to avoid printf-related warnings by casting integer fields whose size may vary to uint64_t and printing them that way.
2020-07-10Fixed const warning in deflate prime tests.Nathan Moinvaziri
zlib-ng.h:1726:10: note: expected ‘const uint8_t * {aka const unsigned char *}’ but argument is of type ‘const char *’
2020-07-01Fixed integer casting and signed comparison warning in test_gzio.Nathan Moinvaziri
example.c(199,57): warning C4267: '=': conversion from 'size_t' to 'int', possible loss of data example.c:207:32: warning: comparison between signed and unsigned integer expressions
2020-07-01Improve deflatePrime test by wrapping gzip header and footer around deflate ↵Nathan Moinvaziri
stream.
2020-06-29Fixed wrong size being used in calloc in test_deflate_set_header.Nathan Moinvaziri
CID 293478 (#1 of 1): Wrong size argument (SIZEOF_MISMATCH) suspicious_sizeof: Passing argument 1UL to function calloc that returns a pointer of type zng_gz_header * is suspicious because a multiple of sizeof (zng_gz_header) /*80*/ is expected.
2020-06-09Use standard int types in zlib-ng api.Nathan Moinvaziri
2020-06-09Fixed variable set but not used static analysis warning in example.Nathan Moinvaziri
example.c:84:14: warning: variable ‘read’ set but not used [-Wunused-but-set-variable] int err, read; example.c:198:5: warning: Value stored to 'read' is never read [deadcode.DeadStores] read = PREFIX(gzfread)(uncompr, uncomprLen, 1, file);
2020-05-30Fixed const correctness when assigning stream next_in.Nathan Moinvaziri
2020-05-30Fixed casting warnings and non-standard initializer warning in example project.Nathan Moinvaziri
2020-05-06Added additional gzio tests for improved code coverage.Nathan Moinvaziri
2020-03-17Remove cvs keywordsPavel P
2020-02-07Fixed formatting, 4 spaces for code intent, 2 spaces for preprocessor ↵Nathan Moinvaziri
indent, initial function brace on the same line as definition, removed extraneous spaces and new lines.
2019-10-22Don't bother computing check value after successful inflateSync().Mark Adler
inflateSync() is used to skip invalid deflate data, which means that the check value that was being computed is no longer useful. This commit turns off the check value computation, and furthermore allows a successful return if the compressed data terminated in a graceful manner. This commit also fixes a bug in the case that inflateSync() is used before a header is ever processed. In that case, there is no knowledge of a trailer, so the remainder is treated as raw.
2019-10-07Fixed use of uninitialized value in test_deflate_copy when deflateCopy is ↵Nathan Moinvaziri
called. #438
2019-09-20Fixed warnings in checksum fuzzer and example. #418Nathan Moinvaziri
2019-09-19In test_deflate_copy(), we free the original struct but forget to free the ↵Hans Kristian Rosbach
copy stuct. Found by msan.
2019-09-19Fixed several warnings in example and fuzzers. #409Nathan Moinvaziri
2019-09-15Add test cases to #437jiangjufa
2019-07-18Add two new public zng_deflate{Set,Get}Params() functionsIlya Leoshkevich
These functions allow zlib-ng callers to modify and query the compression parameters in a future-proof way. When the caller requests a parameter, which is not supported by the current zlib-ng version, this situation is detected and reported to the caller. The caller may modify or query multiple parameters at once. Currently only "level" and "strategy" parameters are supported. It is planned to add a "reproducible" parameter, which would affect whether IBM Z DEFLATE CONVERSION CALL is used. Passing enum and void * buffer was chosen over passing strings, because of simplicity for the caller. If strings were used, C callers would have to call snprintf() and strtoul() for setting and getting integer-valued parameters respectively, which is quite tedious. Bulk updates were chosen over updating individual parameters separately, because it might make sense to apply some parameters atomically, e.g. level and strategy. The new functions are defined only for zlib-ng, but not compat zlib.
2019-06-22Remove duplicate gz functions in test code (#348)Nathan Moinvaziri
Change CMakeLists.txt so that if WITH_GZFILEOP is OFF, gz* sources are still compiled against the tests which need them. Remove duplicate gz functions from test code. Always compile with gz functions when zlib tests enabled in makefile.
2019-03-27Fix building with gcc 8.2.1 and -Wall -Wextra -pedantic -WerrorIlya Leoshkevich
* ptrdiff_t check always failed because of unused parameter * sizeof(void *) check always failed because of double semicolon * Sign issue in nice_match assignment * dist parameter of set_bytes may be unused * Parameters of main may be unused in test/example.c * snprintf requires a _POSIX_C_SOURCE #define in test/minigzip.c, because a _POSIX_SOURCE #define is present
2019-01-24fix bug #289: use strcpy instead of strncpySebastian Pop
to avoid a GCC 8 warning: test/example.c:465:48: warning: argument to ‘sizeof’ in ‘strncpy’ call is the same expression as the source; did you mean to use the size of the destination? [-Wsizeof-pointer-memaccess] strncpy((char*)uncompr, garbage_str, sizeof(garbage_str));
2019-01-10fix several memory sanitizer errors on aarch64Sebastian Pop
With this patch we have a clean run of make test on aarch64 when zlib-ng is configured with --with-msan --with-fuzzers.
2018-11-07Fix test/example.c when compiled with ASANSebastian Pop
Before this patch cmake -DWITH_SANITIZERS=1 make make test used to fail with: Running tests... Test project /home/hansr/github/zlib/zlib-ng Start 1: example 1/2 Test #1: example ..........................***Failed 0.14 sec Start 2: example64 2/2 Test #2: example64 ........................***Failed 0.13 sec ==11605==ERROR: AddressSanitizer: memcpy-param-overlap: memory ranges [0x62e000000595,0x62e0000053b5) and [0x62e000000400, 0x62e000005220) overlap #0 0x7fab3bcc9662 in __asan_memcpy (/usr/lib/x86_64-linux-gnu/libasan.so.2+0x8c662) #1 0x40f936 in memcpy /usr/include/x86_64-linux-gnu/bits/string3.h:53 #2 0x40f936 in read_buf /home/spop/s/zlib-ng/deflate.c:1122 #3 0x410458 in deflate_stored /home/spop/s/zlib-ng/deflate.c:1394 #4 0x4133d7 in zng_deflate /home/spop/s/zlib-ng/deflate.c:945 #5 0x402253 in test_large_deflate /home/spop/s/zlib-ng/test/example.c:275 #6 0x4014e8 in main /home/spop/s/zlib-ng/test/example.c:536 #7 0x7fab3b89382f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2082f) #8 0x4018e8 in _start (/work/spop/zlib-ng/example+0x4018e8) 0x62e000000595 is located 405 bytes inside of 40000-byte region [0x62e000000400,0x62e00000a040) allocated by thread T0 here: #0 0x7fab3bcd579a in __interceptor_calloc (/usr/lib/x86_64-linux-gnu/libasan.so.2+0x9879a) #1 0x40147a in main /home/spop/s/zlib-ng/test/example.c:516 0x62e000000400 is located 0 bytes inside of 40000-byte region [0x62e000000400,0x62e00000a040) allocated by thread T0 here: #0 0x7fab3bcd579a in __interceptor_calloc (/usr/lib/x86_64-linux-gnu/libasan.so.2+0x9879a) #1 0x40147a in main /home/spop/s/zlib-ng/test/example.c:516 SUMMARY: AddressSanitizer: memcpy-param-overlap ??:0 __asan_memcpy ==11605==ABORTING fix bug #183 following recommendations of Mika Lindqvist > the problem is in line c_stream.avail_in = (unsigned int)comprLen/2; > which feeds it too much data ... it should cap it to > c_stream.next_out - compr instead.
2018-03-22Move private defines from zconf.h and zconf-ng.h to zbuild.hMika Lindqvist
* move definition of z_size_t to zbuild.h
2018-03-22[MSVC] Fix size_t/ssize_t when using ZLIB_COMPAT. (#161)Mika Lindqvist
* zconf.h.in wasn't including Windows.h, that is correct header to include definitions from BaseTsd.h, and such missing required type definition for ssize_t when compiling using MS Visual C++ * Various places need implicit casting to z_size_t to get around compatibility issues, this will truncate the result when ZLIB_COMPAT is defined, calling code should check for truncation. * Add ZLIB_COMPAT flag to nmake Makefile and use it to determine correct filenames instead of WITH_GZFILEOP
2018-01-31Adapt code to support PREFIX macros and update build scriptsMika Lindqvist
2017-02-23test/example.c: Don't mix unsigned long and size_t.Mika Lindqvist
2017-02-09zlib 1.2.9Mark Adler
2017-02-01Make globals in examples local to compilation unit.Mark Adler
2017-01-31Replace Z_NULL with NULL. Fix incorrect uses of NULL/Z_NULL.Mika Lindqvist
2015-12-14Use size_t for total_in and total_out.Mika Lindqvist
2015-12-14Type cleanup.Mika Lindqvist
2015-05-23Cleanup user-defined types for 'unsigned char'Mika Lindqvist
* Change 'uch' to 'unsigned char' * Change 'Byte' to 'unsigned char'
2015-05-22Actually set err before checking itHans Kristian Rosbach
2015-05-17Kill Byte and BytefDaniel Axtens
Signed-off-by: Daniel Axtens <dja@axtens.net> Conflicts: adler32.c compress.c deflate.c inflate.c match.c test/example.c uncompr.c zlib.h
2015-05-13z_const -> constDaniel Axtens
Signed-off-by: Daniel Axtens <dja@axtens.net> Conflicts: arch/x86/crc_folding.c crc32.c
2015-05-12Remove support for compiling with Z_SOLO.Hans Kristian Rosbach
Make compiling without gzip file operation support the default (define WITH_GZFILEOP or use --zlib-compat to enable them). Add initial support for compiling in a zlib-compatible mode, this currently only enables gzip file operations and sets the ZLIB_COMPAT flag. Conflicts: test/minigzip.c
2015-04-26Cleanup: Replace 'voidp' with 'void *'Hans Kristian Rosbach
2014-10-18Rewrite K&R-style function prototypes to ANSI-C-style.hansr
Only internal functions, no exported functions in this commit.
2014-10-18Remove FAR variants of voidpfhansr
And a few Bytef leftovers from test/example.c
2014-10-12Remove workarounds for non-ANSI-C compatible compilers (Part 2)hansr
-Removing usage of OF() definition