| Summary: | printf format handling incorrect when asterisk(*) follows format specifier | ||
|---|---|---|---|
| Product: | Busybox | Reporter: | Steve Hein <ssh> |
| Component: | Other | Assignee: | unassigned |
| Status: | RESOLVED FIXED | ||
| Severity: | minor | CC: | busybox-cvs, ssh |
| Priority: | P3 | ||
| Version: | 1.12.x | ||
| Target Milestone: | --- | ||
| Hardware: | All | ||
| OS: | All | ||
| Host: | all | Target: | all |
| Build: | all versions >= 1.12.0 | ||
| Attachments: | Patch to fix printf asterisk bug | ||
Fixed in revision 25506, thanks! |
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).