Some insecure common C Functions

Source: Internet
Author: User
Some insecure common C functions-general Linux technology-Linux programming and kernel information. The following is a detailed description. 1 gets ()
Gets () has the BufferOverflow problem because it cannot specify the size of the buffer to be copied. Specify the Buffer Size by using the substitution function, or use fgets ().

2 scanf ()
Use scanf () instead of scanf_s () or sscanf () as a replacement function.

3 strcpy ()
Strcpy () does not check the Size of the Buffer before copy, so there is a Buffer Overflow problem. Be sure to use functions with high security according to strncpy_s (), strcpy_s (), strncpy () and other environments.

In addition, even if a function with high security is used, Buffer Overflow may also occur due to usage reasons. Pay attention to the following points. Do not perform Buffer Size in strcpy_s () or strncpy_s? .

4 strcat ()
Strcat () does not check the Buffer length, so there is a BufferOverflow problem. Please use according to strncat_s ()? Strcat_s (), strncat (), and other functions with high security. In addition, even if a function with high security is used, BufferOverflow is generated due to usage reasons. Pay attention to the following points. What are the Buffer lengths of strcat_s () and strncat_s? .

5 sprintf ()
Use the highly secure functions prepared by sprintf_s () and snprintf () respectively. In addition, BufferOverflow in very old UNIX/Linux systems, especially in linux libc4's earlier versions, such as snprintf (), is actually unavoidable, so please note.

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.