Menu

#9 Specific String crashes logger. Reproducible

v1.0 (example)
closed
nobody
None
1
2014-12-05
2014-12-05
zbeck
No

A specific String crashes logger. Reproducible every time and easy to test

Try to log this string below.

Example
log4c_category_log(logger, LOG4C_PRIORITY_INFO,
"BAS011ACAA01501170C10039True30$BookingTime \n $FirstName $LastName Id=$RPINTest Enter ID %m/%d/%Y%I:%M %pFalse0True-4806013943484001414911600FalseFalseFalse0");

Note that this crashes. The problem seems to stem from '%m/%d/%Y%I:%M %p' part of the text. I am happy to help to contribute but I need some pointers on where to look and how to get this tested.

Please assist, this is a critical bug. I simply had to remove some of the loggers.
/Z

Discussion

  • František Dvořák

    You should use:

    log4c_category_log(logger, LOG4C_PRIORITY_INFO, "%s", "any string with % here...");

    The "%s" format string is needed also when logging string variable (as it can contains % characters too).

    Also I recommend to switch on the warnings (-Wformat -Wformat-security, or -Wall -Wformat-security). gcc should catch this problem already during compilation.

     
  • zbeck

    zbeck - 2014-12-05

    that worked a lot better.
    Thanks
    /Z

     
  • František Dvořák

    • status: open --> closed
     

Log in to post a comment.