author | Christian Urban <christian dot urban at kcl dot ac dot uk> |
Tue, 08 Oct 2013 05:53:21 +0100 | |
changeset 112 | 0711775cb6b0 |
parent 25 | 599939aad971 |
permissions | -rw-r--r-- |
25 | 1 |
#include <string.h> |
2 |
#include <stdio.h> |
|
3 |
#include <stdlib.h> |
|
4 |
||
5 |
||
6 |
void foo (char *bar) |
|
7 |
{ |
|
8 |
float my_float = 10.5; // in hex: \x41\x28\x00\x00 |
|
9 |
char buffer[28]; |
|
10 |
||
11 |
printf("my float value = %f\n", my_float); |
|
112
0711775cb6b0
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
25
diff
changeset
|
12 |
strcpy(buffer, bar); |
25 | 13 |
printf("my float value = %f\n", my_float); |
14 |
} |
|
15 |
||
16 |
int main (int argc, char **argv) |
|
17 |
{ |
|
18 |
// only float overwritten |
|
19 |
foo("my string is too long !!!!! \x10\x10\xc0\x42"); |
|
20 |
// also calls can_never_run |
|
112
0711775cb6b0
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
25
diff
changeset
|
21 |
foo("my string is too long !!!!! \x10\x10\xc0\x42\x90\x90\x90\x90\x55\x84\x04\x08"); |
25 | 22 |
return 0; |
23 |
} |
|
24 |
||
25 |
// its address in my setup is \x08048455 |
|
26 |
void can_never_run() |
|
27 |
{ |
|
28 |
printf("This can never be executed!\n"); |
|
29 |
exit(0); |
|
30 |
} |
|
31 |
||
32 |