Docsity

CSE 466: Computer Systems Security - Memory Layout and Security Vulnerabilities - Prof. Pa, Study notes of Computer Science

Partial preview of the text

Download CSE 466: Computer Systems Security - Memory Layout and Security Vulnerabilities - Prof. Pa and more Study notes Computer Science in PDF only on Docsity!

CSE 466: Computer Systems Security

Class:

Date:

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