










Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!











Fall 2008
// memory layoutstatic int initial = 1;
// global data
static int non-init;
// BSS segment
void main(int argc, char* argv[]) // stack{
int i = 1, j; //stacstatic int x = 2 // global datastatic int y; // BSS segmentint *buf = malloc (30); // buff on stack, contents on heap }
// call wrong functionvoid good_f(char* str) { … }void main ( );{
static char buf [10]static void (*fptr)(char *str);fptr = &good_flstrncpy(buf, argv[1], strlen(argv[1])fptr(argv[2]); }
// attackable function callsgood-f(char *str) { printf(str) };
// watch out
void main(int argc, char* argv[]){
void (*fptr) (const char str);fptr = &good_f;fptr(“hi ”);
//attackable
Good_f(“there\n”);
//non-attackable