Heap-based Buffer Overflow in the storestring() function
Hi,
While fuzzing dpic 68ab9432 with Hongfuzz, I found a Heap-based Buffer Overflow in the storestring() function, in dpic.y.
Attaching a reproducer, the issue can be reproduced by running: test02
dpic test02
=================================================================
==1522230==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x621000006100 at pc 0x000000527df7 bp 0x7ffcc985f3d0 sp 0x7ffcc985f3c8
WRITE of size 1 at 0x621000006100 thread T0
#0 0x527df6 in storestring /src/dpic/dpic.y:4266:51
#1 0x4fac82 in yyparse /src/dpic/dpic.y:911:5
#2 0x4e67b3 in main /src/dpic/main.c:1795:13
#3 0x7f3bdc9fa0b2 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x270b2)
#4 0x41c48d in _start (/src/dpic/dpic+0x41c48d)
0x621000006100 is located 0 bytes to the right of 4096-byte region [0x621000005100,0x621000006100)
allocated by thread T0 here:
#0 0x4976ed in malloc (/src/dpic/dpic+0x4976ed)
#1 0x5273c4 in storestring /src/dpic/dpic.y:4260:15
SUMMARY: AddressSanitizer: heap-buffer-overflow /src/dpic/dpic.y:4266:51 in storestring
Shadow bytes around the buggy address:
0x0c427fff8bd0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0c427fff8be0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0c427fff8bf0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0c427fff8c00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0c427fff8c10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
=>0x0c427fff8c20:[fa]fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x0c427fff8c30: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x0c427fff8c40: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x0c427fff8c50: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x0c427fff8c60: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x0c427fff8c70: 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
Shadow gap: cc
==1522230==ABORTING