Bug 113 - printf format handling incorrect when asterisk(*) follows format specifier
Summary: printf format handling incorrect when asterisk(*) follows format specifier
Status: RESOLVED FIXED
Alias: None
Product: Busybox
Classification: Unclassified
Component: Other (show other bugs)
Version: 1.12.x
Hardware: All All
: P3 minor
Target Milestone: ---
Assignee: unassigned
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-02-18 16:26 UTC by Steve Hein
Modified: 2009-03-03 14:15 UTC (History)
2 users (show)

See Also:
Host: all
Target: all
Build: all versions >= 1.12.0


Attachments
Patch to fix printf asterisk bug (594 bytes, patch)
2009-02-18 16:26 UTC, Steve Hein
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Steve Hein 2009-02-18 16:26:38 UTC
Created attachment 69 [details]
Patch to fix printf asterisk bug

Starting with version 1.12.0, printf incorrectly handles formatting incorrectly when an asterisk follows any format specifier in the format string.  Here is a simple example:

For any version *before* 1.12.0:

# printf "** %s **\n" "testing"
** testing **

But, for any version 1.12.0 or later:

# printf "** %s **\n" "testing"
** (null) **

The problem is caused by the new have_prec and have_width tests in print_direc().  These are done *before* the format string is temporarily truncated, so the have_width test detects any following asterisk characters.    Simply doing the temporary truncate of the format string before the tests fixes the problem.    The attached patch resolves the problem, and applies cleanly to all versions 1.12.0 through 1.13.3   (haven't tried any other versions).
Comment 1 Denys Vlasenko 2009-03-03 14:15:17 UTC
Fixed in revision 25506, thanks!