C1
authorChristian Urban <urbanc@in.tum.de>
Thu, 04 Oct 2012 13:18:32 +0100
changeset 25 599939aad971
parent 24 525fe544bbe3
child 26 546d7cebc369
C1
programs/C1.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/programs/C1.c	Thu Oct 04 13:18:32 2012 +0100
@@ -0,0 +1,35 @@
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+// for installation notes see C0.c
+
+void foo (char *bar)
+{
+  float my_float = 10.5;    // in hex: \x41\x28\x00\x00
+  char  buffer[28];        
+
+  printf("my float value = %f\n", my_float);
+
+  strcpy(buffer, bar);  
+ 
+  printf("my float value = %f\n", my_float);
+}
+ 
+int main (int argc, char **argv)
+{
+  // only float overwritten
+  foo("my string is too long !!!!! \x10\x10\xc0\x42"); 
+  // also calls can_never_run
+  //foo("my string is too long !!!!! \x10\x10\xc0\x42\x90\x90\x90\x90\x55\x84\x04\x08"); 
+  return 0;
+}
+
+// its address in my setup is \x08048455
+void can_never_run()
+{ 
+  printf("This can never be executed!\n");
+  exit(0);
+}
+
+