在Linux下编写一下代码:
#include <stdio.h>
#include <string.h>
char Lbuffer[] = "01234567890123456789========ABCD";
void foo()
{
char buff[16];
strcpy (buff, Lbuffer);
}
int main(int argc, char * argv[])
{
foo(); return 0;
}
编译命令:
gcc -fno-stack-protector -o h h.c
用gdb调试可执行程序h,计算缓冲区起始地址与函数foo返回地址的距离,下面介绍调试过程
缓冲区的起始地址,即变量buffer的起始地址是:0xbfffefd0