equal
deleted
inserted
replaced
|
1 #include <string.h> |
|
2 #include <stdio.h> |
|
3 #include <stdlib.h> |
|
4 |
|
5 /* |
|
6 I used as environment the virtual machine provided here |
|
7 |
|
8 http://www.cis.upenn.edu/~cis551/box.tar |
|
9 |
|
10 This is Debian/Etch with Linux 2.6.18 with gcc 4.1.2 from 2008. |
|
11 |
|
12 Some installation notes for this virtual machine under VMWare |
|
13 are here |
|
14 |
|
15 http://www.cis.upenn.edu/~cis551/project1.pdf |
|
16 |
|
17 I run the virtial machine under MacOSX using the program |
|
18 VirtualBox available for free from |
|
19 |
|
20 https://www.virtualbox.org |
|
21 |
|
22 The C-program I compiled the program with |
|
23 |
|
24 gcc -ggdb -fno-stack-protector -mpreferred-stack-boundary=2 |
|
25 |
|
26 */ |
|
27 |
|
28 |
|
29 void foo (char *bar) |
|
30 { |
|
31 float my_float = 10.5; // in hex: \x41\x28\x00\x00 |
|
32 char buffer[28]; |
|
33 |
|
34 printf("my float value = %f\n", my_float); |
|
35 |
|
36 strcpy(buffer, bar); |
|
37 |
|
38 printf("my float value = %f\n", my_float); |
|
39 } |
|
40 |
|
41 int main (int argc, char **argv) |
|
42 { |
|
43 foo("my string is too long !!!!! "); // all is normal |
|
44 foo("my string is too long !!!!! \x10\x10\xc0\x42"); // overwrites my_float |
|
45 return 0; |
|
46 } |
|
47 |