Avoiding Buffer Overflows

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

It looks like the article "Avoiding Buffer Overflows"
http://www.linuxsecurity.com/articles/server_security_article-4247.html
has typos, the code there looks like this =>

#include
int main()
  {
     char buff[15] = {0}; /*zero initialize all elements*/
     printf("enter your name: ");
     scanf(buff, "%s");  /*dangerous, length unchecked*/
  }


I am not a master of C, but I think that it should look
like this:

#include <stdio.h>
int main()
 {
   char buff[15] = {0}; /*zero initialize all elements*/
   printf("enter your name: ");
   scanf("%s",buff);  /*dangerous, length unchecked*/
 }

[tech@onix tech]$ ./overflow
enter your name:
lkslkdalksdlskadlksadlkaaslkdaslkdjlaskdlksadlksadlkaslkdaslkdaslkdjlsakdlkasdlksadlka
Segmentation fault (core dumped)

Regards,

David Correa RHCE CCNA
http://www.linux-tech.com


------------------------------------------------------------------------
     To unsubscribe email security-discuss-request@linuxsecurity.com
         with "unsubscribe" in the subject of the message.


[Index of Archives]     [Fedora Announce]     [Linux Crypto]     [Kernel]     [Netfilter]     [Bugtraq]     [USB]     [Fedora Security]

  Powered by Linux