You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
==3850459==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x602000000018 at pc 0x7f325e905786 bp 0x7ffd41264150 sp 0x7ffd412638c8
READ of size 9 at 0x602000000018 thread T0
#0 0x7f325e905785 (/lib64/libasan.so.5+0x55785) #1 0x7f325e907555 in vsnprintf (/lib64/libasan.so.5+0x57555) #2 0x7f325e90782e in __interceptor_snprintf (/lib64/libasan.so.5+0x5782e) #3 0x4009ab in main /tmp/sample.c:11 #4 0x7f325e50e492 in __libc_start_main (/lib64/libc.so.6+0x23492) #5 0x40082d in _start (/tmp/a.out+0x40082d)
0x602000000018 is located 0 bytes to the right of 8-byte region [0x602000000010,0x602000000018)
allocated by thread T0 here:
#0 0x7f325e99fb98 in __interceptor_malloc (/lib64/libasan.so.5+0xefb98) #1 0x400969 in main /tmp/sample.c:9 #2 0x7f325e50e492 in __libc_start_main (/lib64/libc.so.6+0x23492)
it seems ASAN does not recognises "%.0s" format specifier ?
and it seems to continue reading bytes (and overshoot since there is no null terminator ?)
if i change " int j = snprintf(buffer, 4, "%.0s\n", s);" to int j = snprintf(buffer, 4, "%.1s\n", s);
it works fine
The text was updated successfully, but these errors were encountered:
Asan complain buffer overflow in this example
==3850459==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x602000000018 at pc 0x7f325e905786 bp 0x7ffd41264150 sp 0x7ffd412638c8
READ of size 9 at 0x602000000018 thread T0
#0 0x7f325e905785 (/lib64/libasan.so.5+0x55785)
#1 0x7f325e907555 in vsnprintf (/lib64/libasan.so.5+0x57555)
#2 0x7f325e90782e in __interceptor_snprintf (/lib64/libasan.so.5+0x5782e)
#3 0x4009ab in main /tmp/sample.c:11
#4 0x7f325e50e492 in __libc_start_main (/lib64/libc.so.6+0x23492)
#5 0x40082d in _start (/tmp/a.out+0x40082d)
0x602000000018 is located 0 bytes to the right of 8-byte region [0x602000000010,0x602000000018)
allocated by thread T0 here:
#0 0x7f325e99fb98 in __interceptor_malloc (/lib64/libasan.so.5+0xefb98)
#1 0x400969 in main /tmp/sample.c:9
#2 0x7f325e50e492 in __libc_start_main (/lib64/libc.so.6+0x23492)
it seems ASAN does not recognises "%.0s" format specifier ?
and it seems to continue reading bytes (and overshoot since there is no null terminator ?)
if i change " int j = snprintf(buffer, 4, "%.0s\n", s);" to int j = snprintf(buffer, 4, "%.1s\n", s);
it works fine
The text was updated successfully, but these errors were encountered: