25
|
1 |
#include <string.h>
|
|
2 |
#include <stdio.h>
|
|
3 |
#include <stdlib.h>
|
|
4 |
|
|
5 |
// for installation notes see C0.c
|
|
6 |
|
|
7 |
void foo (char *bar)
|
|
8 |
{
|
|
9 |
float my_float = 10.5; // in hex: \x41\x28\x00\x00
|
|
10 |
char buffer[28];
|
|
11 |
|
|
12 |
printf("my float value = %f\n", my_float);
|
|
13 |
|
|
14 |
strcpy(buffer, bar);
|
|
15 |
|
|
16 |
printf("my float value = %f\n", my_float);
|
|
17 |
}
|
|
18 |
|
|
19 |
int main (int argc, char **argv)
|
|
20 |
{
|
|
21 |
// only float overwritten
|
|
22 |
foo("my string is too long !!!!! \x10\x10\xc0\x42");
|
|
23 |
// also calls can_never_run
|
|
24 |
//foo("my string is too long !!!!! \x10\x10\xc0\x42\x90\x90\x90\x90\x55\x84\x04\x08");
|
|
25 |
return 0;
|
|
26 |
}
|
|
27 |
|
|
28 |
// its address in my setup is \x08048455
|
|
29 |
void can_never_run()
|
|
30 |
{
|
|
31 |
printf("This can never be executed!\n");
|
|
32 |
exit(0);
|
|
33 |
}
|
|
34 |
|
|
35 |
|