提问人:gopher 提问时间:11/1/2023 最后编辑:gopher 更新时间:11/1/2023 访问量:69
GCC 缺少 AddressSanitizer 错误位置
AddressSanitizer Error Location Missing with GCC
问:
此命令不显示 AddressSanitizer 摘要错误位置。gcc uaf.c -o uaf -fsanitize=address -static-libasan
代码如下:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(int argc, const char *argv[]) {
char *s = malloc(100);
free(s);
strcpy(s, "Hello world!");
printf("string is: %s\n", s);
return 0;
}
这是我所看到的:
=================================================================
==1017908==ERROR: AddressSanitizer: heap-use-after-free on address 0x60b0000000f0 at pc 0x5623a332bb53 bp 0x7fff85504890 sp 0x7fff85504038
WRITE of size 13 at 0x60b0000000f0 thread T0
#0 0x5623a332bb52 in memcpy (/home/test/work/uaf+0x1db52)
#1 0x5623a33ebcd5 in main (/home/test/work/uaf+0xddcd5)
#2 0x7f226558ad8f (/lib/x86_64-linux-gnu/libc.so.6+0x29d8f)
#3 0x7f226558ae3f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e3f)
#4 0x5623a33163a4 in _start (/home/test/work/uaf+0x83a4)
0x60b0000000f0 is located 0 bytes inside of 100-byte region [0x60b0000000f0,0x60b000000154)
freed by thread T0 here:
#0 0x5623a33a5da7 in free (/home/test/work/uaf+0x97da7)
#1 0x5623a33ebcba in main (/home/test/work/uaf+0xddcba)
#2 0x7f226558ad8f (/lib/x86_64-linux-gnu/libc.so.6+0x29d8f)
previously allocated by thread T0 here:
#0 0x5623a33a60f7 in malloc (/home/test/work/uaf+0x980f7)
#1 0x5623a33ebcaa in main (/home/test/work/uaf+0xddcaa)
#2 0x7f226558ad8f (/lib/x86_64-linux-gnu/libc.so.6+0x29d8f)
SUMMARY: AddressSanitizer: heap-use-after-free (/home/test/work/uaf+0x1db52) in memcpy
Shadow bytes around the buggy address:
这是我在摘要部分所期望的:
SUMMARY: AddressSanitizer: heap-use-after-free /home/test/work/uaf.c:8 in memcpy
我在这里错过了什么?
我正在使用这个博客作为参考 https://www.osc.edu/resources/getting_started/howto/howto_use_address_sanitizer
答: 暂无答案
评论
-g
显然地。线号信息还从何而来?gcc uaf.c -o uaf -fsanitize=address -static-libasan -g
gcc uaf.c -o uaf -fsanitize=address -g
-static-libasan