# HG changeset patch # User Christian Urban # Date 1412434505 -3600 # Node ID c75a03ab8ac9a5ec903d7acba54c687e4bf9d3fd # Parent 6740798264c15e229c2fde59452b513324922366 test diff -r 6740798264c1 -r c75a03ab8ac9 progs/test.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/progs/test.c Sat Oct 04 15:55:05 2014 +0100 @@ -0,0 +1,47 @@ +#include +#include +#include + +/* + I used as environment the virtual machine provided here + + http://www.cis.upenn.edu/~cis551/box.tar + + This is Debian/Etch with Linux 2.6.18 with gcc 4.1.2 from 2008. + + Some installation notes for this virtual machine under VMWare + are here + + http://www.cis.upenn.edu/~cis551/project1.pdf + + I run the virtial machine under MacOSX using the program + VirtualBox available for free from + + https://www.virtualbox.org + + The C-program I compiled the program with + + gcc -ggdb -fno-stack-protector -mpreferred-stack-boundary=2 + + */ + + +void foo (char *bar) +{ + long my_long = 10; // in hex: \xF2\x03\x00\x00 + char buffer[28]; + + printf("my_long value = %lu\n", my_long); + + strcpy(buffer, bar); + + printf("my_long value = %lu\n", my_long); +} + +int main (int argc, char **argv) +{ + foo("my string is too long !!!!! "); // all is normal + foo("my string is too long !!!!! \x00\x00\x07\xE4"); // overwrites my_long + return 0; +} +