In one form of attack the exploit code then uses a

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: e 35). In addition, the expression up->v (line 33) both derefences pointer up and selects field v. ¯ 3.11. PUTTING IT TOGETHER: UNDERSTANDING POINTERS 163 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 struct str { int t; char v; }; union uni { int t; char v; } u; int g = 15; /* Example Structure */ /* Example Union */ void fun(int* xp) { void (*f)(int*) = fun; /* f is a function pointer */ /* Allocate structure on stack */ struct str s = {1,’a’}; /* Initialize structure */ /* Allocate union from heap */ union uni *up = (union uni *) malloc(sizeof(union uni)); /* Locally declared array */ int *ip[2] = {xp, &g}; up->v = s.v+1; printf("ip = %p, *ip = %p, **ip = %d\n", ip, *ip, **ip); printf("ip+1 = %p, ip[1] = %p, *ip[1] = %d\n", ip+1, ip[1], *ip[1]); printf("&s.v = %p, s.v = ’%c’\n", &s.v, s.v); printf("&up->v = %p, up->v = ’%c’\n", &up->v, up->v); printf("f = %p\n", f); if (--(*xp) > 0) f(xp); /* Recursive call of fun */...
View Full Document

This note was uploaded on 09/02/2010 for the course ELECTRICAL 360 taught by Professor Schultz during the Spring '10 term at BYU.

Ask a homework question - tutors are online