sprintf buffer global data overflow - how to detect it, Windows
问题 I am wondering if it's possible to detect this kind of buffer overflow somehow in Windows. Buffer is global ( not on stack ) so /RTC in Visual Studio 2008, VS2012 is not checking it. MinGW gcc also failed. #include <stdio.h> char buffer[2]; void main() { sprintf(buffer,"12345"); } My first thought was static analysis. VS2012 Code Analysis : nothing CppCheck: nothing PCLint Online: nothing ( http://www.gimpel-online.com/OnlineTesting.html ) PVS-Studio: nothing another solution is to use _s