Program crashes due to formatted output

Source: Internet
Author: User
After running a program on the server for a while, the process does not exist.
Release core file limit: Ulimit-c Unlimited
Waiting to produce core files
Analyze core Files
(GDB) bt
#0 0x008711d3 in strlen () from/lib/libc.so.6
#1 0x00840c0e in vfprintf () from/lib/libc.so.6
#2 0x008613f4 in vsnprintf () from/lib/libc.so.6
#3 0x00846ec5 in snprintf () from/lib/libc.so.6
#4 0x08050598 in Chashmdm::add (this=0x8073000, domain=0x2f36925c "xn--chinaka%64s-.com", tfrstvst=1372868283,
nhouravgfrqncy=30) at./src/chashmdm.cpp:36
#5 0x0805244d in Ctasktime::run (this=0x9d712d0) at./src/ctasktime.cpp:117
#6 0x080589f6 in ThreadRun (pthread=0x9d712d0) at src/common/thread.cpp:24
#7 0x0097d832 in Start_thread () from/lib/libpthread.so.0
#8 0x008d2e0e in Clone () from/lib/libc.so.6
(GDB) L chashmdm.cpp:36
snprintf (data.dm, sizeof (DATA.DM), DM);

The formatted output was omitted:, "%s", causing snprintf to take the next parameter domain as a format string, when encountering the URL xn--chinaka%64s-.com, the%64s as a format character to explain,
But without the%64s parameters, the program crashes.

Reference:

format string Attack


In fact, this is a function call less parameters of the low-level error, but the compiler has a reasonable explanation without error.

Do not rely on editors, compilers. Basic skills should be solid. Write programs to concentrate.

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.