This repository has been archived by the owner on Sep 3, 2020. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix test/example.c when compiled with ASAN
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 madler#1: example ..........................***Failed 0.14 sec Start 2: example64 2/2 Test madler#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) madler#1 0x40f936 in memcpy /usr/include/x86_64-linux-gnu/bits/string3.h:53 madler#2 0x40f936 in read_buf /home/spop/s/zlib-ng/deflate.c:1122 madler#3 0x410458 in deflate_stored /home/spop/s/zlib-ng/deflate.c:1394 madler#4 0x4133d7 in zng_deflate /home/spop/s/zlib-ng/deflate.c:945 madler#5 0x402253 in test_large_deflate /home/spop/s/zlib-ng/test/example.c:275 madler#6 0x4014e8 in main /home/spop/s/zlib-ng/test/example.c:536 madler#7 0x7fab3b89382f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2082f) madler#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) madler#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) madler#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 madler#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.
- Loading branch information