#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void h(void)
{...}{
printf("h ");
}
void g(int para)
{...}{
int arr[128];
int *tmp = (int*)malloc(4);
int* buf1 = (int*)malloc(4);
int* buf2 = (int*)malloc(4);
int steps = buf1 - buf2;
memset(arr, 0xfd, steps*4 );
arr[steps++] = (int)¶-4;
memcpy( buf2, arr, steps*4 ); //堆缓冲区溢出
*(int*)(*buf1) = (int)&h;
free(tmp);
// free(buf1);
free(buf2);
}
int main()
{...}{
g(0);
return 0;
}

//运行结果(VC6.0):
h
1491

被折叠的 条评论
为什么被折叠?



