stack-buffer-overflow in function put_float()
ATasm is a 6502 command-line cross-assembler.
Brought to you by:
schmelze
Hi,
While fuzzing ATasm 1.09, I found stack-buffer-overflow in function put_float(),in asm.c
in the function put_float() in asm.c
the tmp array size is 64: 634 char tmp[64],buf[64],*look,*walk;
,
in line 660 660 strcat(tmp,look);
didn't check the length of look and then result in a stack buffer overflow.
==4044063==ERROR: AddressSanitizer: stack-buffer-overflow on address 0x7ffc7a6ca300 at pc 0x7f6cea999cbd bp 0x7ffc7a6ca240 sp 0x7ffc7a6c99e8
READ of size 73 at 0x7ffc7a6ca300 thread T0
#0 0x7f6cea999cbc (/usr/lib/x86_64-linux-gnu/libasan.so.5+0x74cbc)
#1 0x55859308ed68 in put_float /home/goushi/john/atasm/src-afl-gcc/asm.c:663
#2 0x5585930960ee in do_float /home/goushi/john/atasm/src-afl-gcc/asm.c:1207
#3 0x5585930a121a in proc_sym /home/goushi/john/atasm/src-afl-gcc/asm.c:1600
#4 0x5585930a5f4a in do_cmd /home/goushi/john/atasm/src-afl-gcc/asm.c:1995
#5 0x5585930a6424 in assemble /home/goushi/john/atasm/src-afl-gcc/asm.c:2034
#6 0x558593084341 in main /home/goushi/john/atasm/src-afl-gcc/asm.c:2446
#7 0x7f6cea73e0b2 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x270b2)
#8 0x558593085ddd in _start (/home/goushi/john/atasm/src-afl-gcc/atasm+0xdddd)
Address 0x7ffc7a6ca300 is located in stack of thread T0 at offset 128 in frame
#0 0x55859308e8ff in put_float /home/goushi/john/atasm/src-afl-gcc/asm.c:633
This frame has 3 object(s):
[32, 44) 'n' (line 635)
[64, 128) 'tmp' (line 634)
[160, 224) 'buf' (line 634) <== Memory access at offset 128 partially underflows this variable
HINT: this may be a false positive if your program uses some custom stack unwind mechanism, swapcontext or vfork
(longjmp and C++ exceptions *are* supported)
SUMMARY: AddressSanitizer: stack-buffer-overflow (/usr/lib/x86_64-linux-gnu/libasan.so.5+0x74cbc)
Shadow bytes around the buggy address:
0x10000f4d1410: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x10000f4d1420: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x10000f4d1430: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x10000f4d1440: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x10000f4d1450: f1 f1 f1 f1 00 04 f2 f2 00 00 00 00 00 00 00 00
=>0x10000f4d1460:[f2]f2 f2 f2 00 00 00 00 00 00 00 00 f3 f3 f3 f3
0x10000f4d1470: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x10000f4d1480: f1 f1 f1 f1 00 00 00 00 f2 f2 f2 f2 00 00 00 00
0x10000f4d1490: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x10000f4d14a0: 00 00 00 00 00 00 00 00 00 00 00 00 f3 f3 f3 f3
0x10000f4d14b0: f3 f3 f3 f3 00 00 00 00 00 00 00 00 00 00 00 00
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
==4044063==ABORTING
reproduce:
atasm stack_buffer_over_02_put_float