Handle CIDR Block errors of vfprintf in C Language

Source: Internet
Author: User

The CIDR Block Error of C language must have been encountered by everyone. Sort it out for learning.

Today, I executed a program. after a long time of running, the segment was incorrect. I located it and it turned out to be a problem with fprintf, specifically the problem with vfprintf.

Program received signal SIGSEGV, Segmentation fault. 0x0098735e in vfprintf () from/lib/libc. so.6


The call stack is:

#0 0x0098735e in vfprintf () from/lib/libc. so.6
#1 0x0098e3cf in fprintf () from/lib/libc. so.6
Replace fprintf with printf.

I started to think it was a length problem that caused overflow. Later I combined various solutions and found that it was not a length problem. It was originally a problem caused by a special character sequence, the culprit is the string % 20, which causes the vfprintf to run abnormally. % 20 is actually the url encoding of spaces.

The above is mainly caused by the variable parameter list and the character string formatting feature. For example, the % 20s sequence is considered to be a string, but we didn't input a string, so the program will be faulty. In general, as long as the string contains %, even if there is no segment error, there will be a very strange output phenomenon.

Similarly, because sprintf also calls vfprintf, it should also have problems.

 


 

Related Article

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.