progs/test.c
changeset 208 204564b899a0
parent 205 88416b7df38c
child 211 e6e160c7ea33
equal deleted inserted replaced
207:e74a45933842 208:204564b899a0
     1 #include <string.h>
     1 #include <string.h>
     2 #include <stdio.h>
     2 #include <stdio.h>
     3 #include <stdlib.h>
     3 #include <stdlib.h>
     4 
     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)
     5 void foo (char *bar)
    30 {
     6 {
    31   unsigned long long my_long = 101010101;    // in hex: \xB5\x4A\x05\x06
     7   unsigned long my_long = 101010101;    // in hex: \xB5\x4A\x05\x06
    32   char  buffer[28];        
     8   char  buffer[28];        
    33 
     9 
    34   printf("my_long value = %llu\n", my_long);
    10   printf("my_long value = %lu\n", my_long);
    35 
    11 
    36   strcpy(buffer, bar);  
    12   strcpy(buffer, bar);  
    37  
    13  
    38   printf("my_long value = %llu\n", my_long);
    14   printf("my_long value = %lu\n", my_long);
    39 }
    15 }
    40  
    16  
    41 int main (int argc, char **argv)
    17 int main (int argc, char **argv)
    42 {
    18 {
    43   foo("my string is too long !!!!!");                  // all is normal
    19   foo("my string is too long !!!!!");                  // all is normal