author | Christian Urban <christian dot urban at kcl dot ac dot uk> |
Mon, 06 Oct 2014 00:57:44 +0100 | |
changeset 205 | 88416b7df38c |
parent 203 | c75a03ab8ac9 |
child 208 | 204564b899a0 |
permissions | -rw-r--r-- |
203
c75a03ab8ac9
test
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1 |
#include <string.h> |
c75a03ab8ac9
test
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2 |
#include <stdio.h> |
c75a03ab8ac9
test
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
3 |
#include <stdlib.h> |
c75a03ab8ac9
test
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
4 |
|
c75a03ab8ac9
test
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
5 |
/* |
c75a03ab8ac9
test
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
6 |
I used as environment the virtual machine provided here |
c75a03ab8ac9
test
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
7 |
|
c75a03ab8ac9
test
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
8 |
http://www.cis.upenn.edu/~cis551/box.tar |
c75a03ab8ac9
test
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
9 |
|
c75a03ab8ac9
test
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
10 |
This is Debian/Etch with Linux 2.6.18 with gcc 4.1.2 from 2008. |
c75a03ab8ac9
test
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
11 |
|
c75a03ab8ac9
test
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
12 |
Some installation notes for this virtual machine under VMWare |
c75a03ab8ac9
test
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
13 |
are here |
c75a03ab8ac9
test
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
14 |
|
c75a03ab8ac9
test
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
15 |
http://www.cis.upenn.edu/~cis551/project1.pdf |
c75a03ab8ac9
test
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
16 |
|
c75a03ab8ac9
test
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
17 |
I run the virtial machine under MacOSX using the program |
c75a03ab8ac9
test
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
18 |
VirtualBox available for free from |
c75a03ab8ac9
test
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
19 |
|
c75a03ab8ac9
test
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
20 |
https://www.virtualbox.org |
c75a03ab8ac9
test
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
21 |
|
c75a03ab8ac9
test
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
22 |
The C-program I compiled the program with |
c75a03ab8ac9
test
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
23 |
|
c75a03ab8ac9
test
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
24 |
gcc -ggdb -fno-stack-protector -mpreferred-stack-boundary=2 |
c75a03ab8ac9
test
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
25 |
|
c75a03ab8ac9
test
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
26 |
*/ |
c75a03ab8ac9
test
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
27 |
|
c75a03ab8ac9
test
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
28 |
|
c75a03ab8ac9
test
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
29 |
void foo (char *bar) |
c75a03ab8ac9
test
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
30 |
{ |
205
88416b7df38c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
203
diff
changeset
|
31 |
unsigned long long my_long = 101010101; // in hex: \xB5\x4A\x05\x06 |
203
c75a03ab8ac9
test
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
32 |
char buffer[28]; |
c75a03ab8ac9
test
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
33 |
|
205
88416b7df38c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
203
diff
changeset
|
34 |
printf("my_long value = %llu\n", my_long); |
203
c75a03ab8ac9
test
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
35 |
|
c75a03ab8ac9
test
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
36 |
strcpy(buffer, bar); |
c75a03ab8ac9
test
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
37 |
|
205
88416b7df38c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
203
diff
changeset
|
38 |
printf("my_long value = %llu\n", my_long); |
203
c75a03ab8ac9
test
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
39 |
} |
c75a03ab8ac9
test
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
40 |
|
c75a03ab8ac9
test
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
41 |
int main (int argc, char **argv) |
c75a03ab8ac9
test
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
42 |
{ |
205
88416b7df38c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
203
diff
changeset
|
43 |
foo("my string is too long !!!!!"); // all is normal |
88416b7df38c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
203
diff
changeset
|
44 |
foo("my string is too long !!!!! \x15\xcd\x5b\x07"); // overwrites my_long |
203
c75a03ab8ac9
test
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
45 |
return 0; |
c75a03ab8ac9
test
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
46 |
} |
c75a03ab8ac9
test
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
47 |