感谢万能的互联网,我向google提出的issue很快就得到了工程师回复,解决了我的问题。
我的问题是这样的:
AddressSanitizer can't detect some global buffer overflow! #1285
Closed
yangyongzhen opened this issue yesterday · 1 comment
yangyongzhen commented yesterday
what a pity! AddressSanitizer can't detect some global buffer overflow! Even if the mistake or code bugs is so obvious。 for example,this code bellow, guess what you will get, U08 IP[10]; printf("IP1[0]:%d\n",IP1[0]); printf("IP[10]:%d\n",IP[10]); printf("IP1[0]:%d\n",IP1[0]); 。。。。。。 use cflags= -std=gnu99 -Wall -fno-stack-protector -fno-omit-frame-pointer -fvar-tracking -g2 -fno-inline -fsanitize=address -fexceptions but AddressSanitizer can't detect this!!! if you add "static" before the global vars,like this: static U08 IP[10]; |
melver commented 23 hours ago
Add -fno-common for C code. Globals that are placed in the common section (default for C) won't be separated by redzones, and therefore the OOB accesses in your example simply access IP1's memory. |