No Buffer Overflow

Jason Dusek jason-dusek at
Sun Oct 17 15:35:19 PDT 2004

Hi Everyone,

I am reading an intro to shell-coding, and the following program is used as a 
simple example of vulnerable code:

   /* vuln.c */

   main(int argc, char **argv, char **envp)
     char buf[256];
     strcpy(buf, argv[1]);

     return 0;

When I run this code like this:

   18 > vuln
   Segmentation fault (core dumped)

it segfaults, like the tutorial says. In the tutorial this line:

   19 > vuln `perl -e 'print "A"x256 . "BBBB" . "CCCC"'`

also segfaults, but not on my machine. Is this some FreeBSD security feature?

   20 > uname -a
   FreeBSD localhost 5.3-BETA2
   FreeBSD 5.3-BETA2 #0: Mon Sep  6 15:27:56 CDT 2004
   root at localhost:/usr/obj/usr/src/sys/CUSTOM  i386

If this doesn't cause a segfault, does it still overflow?


More information about the freebsd-questions mailing list