[root@fedora kamby]# make
clang -fsanitize=address,undefined -c -fpic -o kamby.o kamby.c
clang -fsanitize=address,undefined -shared -o libkamby.so kamby.o
rm kamby.o
clang -fsanitize=address,undefined -o kamby main.c kamby.c
[root@fedora kamby]# make test
clang -fsanitize=address,undefined -c -fpic -o kamby.o kamby.c
clang -fsanitize=address,undefined -shared -o libkamby.so kamby.o
rm kamby.o
clang -fsanitize=address,undefined -o tests tests.c -L`pwd` -lkamby
TESTING...
- Initialization
=================================================================
==997==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x602000000013 at pc 0x000000447f5a bp 0x7fffc64a3e90 sp 0x7fffc64a3650
WRITE of size 4 at 0x602000000013 thread T0
#0 0x447f59 in __interceptor_strcpy.part.0 asan_interceptors.cpp.o
#1 0x7f25902fae83 in ka_idf (/root/kamby/libkamby.so+0xde83) (BuildId: 57fe31e0ce1eb6ef4c07b16b7a75f7c740f59fec)
#2 0x7f259030c052 in ka_init (/root/kamby/libkamby.so+0x1f052) (BuildId: 57fe31e0ce1eb6ef4c07b16b7a75f7c740f59fec)
#3 0x51275b in test_init (/root/kamby/tests+0x51275b) (BuildId: 4487b6b2fc988d4eb27ee1a3afc04555cf122ae5)
#4 0x517724 in main (/root/kamby/tests+0x517724) (BuildId: 4487b6b2fc988d4eb27ee1a3afc04555cf122ae5)
#5 0x7f259002da4f in __libc_start_call_main (/lib64/libc.so.6+0x23a4f) (BuildId: 705c3497077980e84480c5ea1f24241b72863722)
#6 0x7f259002db08 in __libc_start_main@GLIBC_2.2.5 (/lib64/libc.so.6+0x23b08) (BuildId: 705c3497077980e84480c5ea1f24241b72863722)
#7 0x41d3c4 in _start (/root/kamby/tests+0x41d3c4) (BuildId: 4487b6b2fc988d4eb27ee1a3afc04555cf122ae5)
0x602000000013 is located 0 bytes to the right of 3-byte region [0x602000000010,0x602000000013)
allocated by thread T0 here:
#0 0x4cfa97 in __interceptor_malloc (/root/kamby/tests+0x4cfa97) (BuildId: 4487b6b2fc988d4eb27ee1a3afc04555cf122ae5)
#1 0x7f25902fac12 in ka_idf (/root/kamby/libkamby.so+0xdc12) (BuildId: 57fe31e0ce1eb6ef4c07b16b7a75f7c740f59fec)
#2 0x7f259030c052 in ka_init (/root/kamby/libkamby.so+0x1f052) (BuildId: 57fe31e0ce1eb6ef4c07b16b7a75f7c740f59fec)
#3 0x51275b in test_init (/root/kamby/tests+0x51275b) (BuildId: 4487b6b2fc988d4eb27ee1a3afc04555cf122ae5)
#4 0x517724 in main (/root/kamby/tests+0x517724) (BuildId: 4487b6b2fc988d4eb27ee1a3afc04555cf122ae5)
#5 0x7f259002da4f in __libc_start_call_main (/lib64/libc.so.6+0x23a4f) (BuildId: 705c3497077980e84480c5ea1f24241b72863722)
SUMMARY: AddressSanitizer: heap-buffer-overflow asan_interceptors.cpp.o in __interceptor_strcpy.part.0
Shadow bytes around the buggy address:
0x0c047fff7fb0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0c047fff7fc0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0c047fff7fd0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0c047fff7fe0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0c047fff7ff0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
=>0x0c047fff8000: fa fa[03]fa fa fa 03 fa fa fa fa fa fa fa fa fa
0x0c047fff8010: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x0c047fff8020: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x0c047fff8030: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x0c047fff8040: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x0c047fff8050: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
Shadow byte legend (one shadow byte represents 8 application bytes):
Addressable: 00
Partially addressable: 01 02 03 04 05 06 07
Heap left redzone: fa
Freed heap region: fd
Stack left redzone: f1
Stack mid redzone: f2
Stack right redzone: f3
Stack after return: f5
Stack use after scope: f8
Global redzone: f9
Global init order: f6
Poisoned by user: f7
Container overflow: fc
Array cookie: ac
Intra object redzone: bb
ASan internal: fe
Left alloca redzone: ca
Right alloca redzone: cb
==997==ABORTING
make: *** [Makefile:33: test] Error 1
#