Buffer overflow (READ of size 1) in the get_nxt_word() function
ATasm is a 6502 command-line cross-assembler.
Brought to you by:
schmelze
Hi,
While fuzzing ATasm 1.09, I found a buffer overflow in the get_nxt_word() function, asm.c
Attaching a reproducer, issue can be reproduced by running:
atasm get_nxt_word_test01
ATasm 1.09 (A mostly Mac65 compatible 6502 cross-assembler)
Pass 1: =================================================================
==11689==ERROR: AddressSanitizer: global-buffer-overflow on address 0x000000e1771f at pc 0x0000004ceb53 bp 0x7fffa438d130 sp 0x7fffa438d128
READ of size 1 at 0x000000e1771f thread T0
#0 0x4ceb52 in get_nxt_word /src/atasm109/src/asm.c:478:13
#1 0x4e8add in assemble /src/atasm109/src/asm.c:2007:11
#2 0x4eb4c7 in main /src/atasm109/src/asm.c:2421:3
#3 0x7f4962f290b2 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x270b2)
#4 0x41c5ed in _start (/src/atasm109/src/atasm+0x41c5ed)
0x000000e1771f is located 1 bytes to the left of global variable 'line' defined in 'asm.c:372:25' (0xe17720) of size 256
0x000000e1771f is located 63 bytes to the right of global variable 'buf' defined in 'asm.c:372:15' (0xe175e0) of size 256
SUMMARY: AddressSanitizer: global-buffer-overflow /src/atasm109/src/asm.c:478:13 in get_nxt_word
Shadow bytes around the buggy address:
0x0000801bae90: f9 f9 f9 f9 00 f9 f9 f9 f9 f9 f9 f9 00 f9 f9 f9
0x0000801baea0: f9 f9 f9 f9 00 f9 f9 f9 f9 f9 f9 f9 04 f9 f9 f9
0x0000801baeb0: f9 f9 f9 f9 00 f9 f9 f9 f9 f9 f9 f9 00 00 00 00
0x0000801baec0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0000801baed0: 00 00 00 00 00 00 00 00 00 00 00 00 f9 f9 f9 f9
=>0x0000801baee0: f9 f9 f9[f9]00 00 00 00 00 00 00 00 00 00 00 00
0x0000801baef0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0000801baf00: 00 00 00 00 f9 f9 f9 f9 f9 f9 f9 f9 00 f9 f9 f9
0x0000801baf10: f9 f9 f9 f9 04 f9 f9 f9 f9 f9 f9 f9 00 00 00 00
0x0000801baf20: 00 00 f9 f9 f9 f9 f9 f9 02 f9 f9 f9 f9 f9 f9 f9
0x0000801baf30: 04 f9 f9 f9 f9 f9 f9 f9 04 f9 f9 f9 f9 f9 f9 f9
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
==11689==ABORTING