Advertisement
miguelangelgarcia

BufferOverflowExample

May 10th, 2014
651
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.32 KB | None | 0 0
  1. #include <string.h>
  2. #include <stdio.h>
  3. #include <unistd.h>
  4.  
  5. void greet (char *arg)
  6. {
  7.     char name[32];
  8.     strcpy(name, arg);
  9.     printf("Hi %s\n", name);
  10. }
  11.  
  12. int main (int argc, char *argv[])
  13. {
  14.     sleep(1);
  15.    
  16.     if(argc!=2)
  17.     {
  18.         printf("Example: %s NAME\n", argv[0]);
  19.     }
  20.     else
  21.     {
  22.         greet(argv[1]);
  23.     }
  24.    
  25.     return 0;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement