Windows buffer Overflow Vulnerability-unsafe function

Source: Internet
Author: User

#include  <stdio.h>//#define  sz1  "Hello" Int main (int argc, char *argv[ ]) {    //char sz1[8] =  "Hello";     //const char  *sz1 =  "Hello";     char sz1[8];    char sz2[ 8];    memset (sz1,0x00,sizeof (SZ1));     strcpy (sz1, "Hello");     printf ("sz1=[%s]\n", sz1);     while (1)     {         memset (sz2,0x00,sizeof (SZ2));         printf ("please input passwd:\n");          / /gets (SZ2); &NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;SCANF ("%s", SZ2);         //fgets (Sz2,sizeof (SZ2), stdin);         printf ("--- Sz1=[%s]\n ", sz1);   &nBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;PRINTF ("---sz2=[%s]\n", sz2);         if (0 == strcmp (SZ1,SZ2))         {                          printf ("----hello world-----\ n");             break;        }         else        {             printf ("----ERROR----\ n");             continue;        }    }     return 0;}


-----------------Test Results---------------

Sz1=[hello]

Please input passwd:

12345678ayang

---Sz1=[ayang]

---Sz2=[12345678ayang]

----ERROR----

Please input passwd:

Hello

---Sz1=[ayang]

---Sz2=[hello]

----ERROR----

Please input passwd:

Ayang

---Sz1=[ayang]

---Sz2=[ayang]

----Hello World-----


Windows buffer Overflow Vulnerability-unsafe function

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.