{
char bufBef[32];
char buf[8];
char bufAfter[32];
sprintf(buf,"AAAAAAA\0");
buf[8]='\0';
printf("%s\n",buf);
}
In Windows 7, I compiled the program with Visual Studio 2008 as a debugging project. 3 buffers are adjacent. I find their addresses with the debugger, as follows:
bufBef 0x001afa50
buf 0x001afa40
bufAfter 0x001afa18
The buf [8] = '\ 0' โstatement writes the address from buf. When I run the program, the operating system reportedโ Debugging error: execution verification error at run time # 2. โDamage from the buf variable was damaged.
Then I compiled it as a release project. It works quietly, the error report does not rise.
My question is, how is buffer overflow at runtime?
source
share