chunli@blog:~/source$ date Wed 30 Nov 2022 06:38:20 PM CST chunli@blog:~/source$
软件
1 2 3 4 5 6
chunli@blog:~/source$ gcc --version gcc (Debian 10.2.1-6) 10.2.1 20210110 Copyright (C) 2020 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. chunli@blog:~/source$
错误的说明很有用, 指出了 gcc_asan_test.c:7 存在 stack-buffer-overflow ================================================================= ==420560==ERROR: AddressSanitizer: stack-buffer-overflow on address 0x7ffe05f9017a at pc 0x7f37b961c8a1 bp 0x7ffe05f90100 sp 0x7ffe05f8f8b0 WRITE of size 32 at 0x7ffe05f9017a thread T0 #0 0x7f37b961c8a0 in __interceptor_memcpy ../../../../src/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc:806 #1 0x5589aebaa1cc in fun1 /home/chunli/source/gcc_asan_test.c:7 #2 0x5589aebaa263 in main /home/chunli/source/gcc_asan_test.c:15 #3 0x7f37b9431d09 in __libc_start_main ../csu/libc-start.c:308 #4 0x5589aebaa0d9 in _start (/home/chunli/source/a.out+0x10d9)
Address 0x7ffe05f9017a is located in stack of thread T0 at offset 42 in frame #0 0x5589aebaa1e3 in main /home/chunli/source/gcc_asan_test.c:12
chunli@blog:~/source$ ./a.out ================================================================= ==420593==ERROR: AddressSanitizer: stack-buffer-overflow on address 0x7fff926b734a at pc 0x56083c88c121 bp 0x7fff926b72d0 sp 0x7fff926b6a80 WRITE of size 32 at 0x7fff926b734a thread T0 #0 0x56083c88c120 in __interceptor_memcpy (/home/chunli/source/a.out+0x1e120) #1 0x56083c93b74c in fun1 /home/chunli/source/gcc_asan_test.c:7 #2 0x56083c93b7e3 in main /home/chunli/source/gcc_asan_test.c:15 #3 0x7f91d1223d09 in __libc_start_main ../csu/libc-start.c:308 #4 0x56083c876419 in _start (/home/chunli/source/a.out+0x8419)
Address 0x7fff926b734a is located in stack of thread T0 at offset 42 in frame #0 0x56083c93b763 in main /home/chunli/source/gcc_asan_test.c:12