Correct handling of format strings with escaped % specifications.
Note: It would be nice to be able to implement getformat() using fmtcheck(3), but fmtcheck does not distinguish between signed and unsigned types, a facility jot needs to perform range checks on its output. Submitted by: Per Kristian Hove MFC after: 2 weeks
This commit is contained in:
parent
86ce72fe0a
commit
552b6c0ead
@ -393,8 +393,11 @@ getformat(void)
|
||||
if (boring) /* no need to bother */
|
||||
return;
|
||||
for (p = format; *p; p++) /* look for '%' */
|
||||
if (*p == '%' && *(p+1) != '%') /* leave %% alone */
|
||||
break;
|
||||
if (*p == '%')
|
||||
if (p[1] == '%')
|
||||
p++; /* leave %% alone */
|
||||
else
|
||||
break;
|
||||
sz = sizeof(format) - strlen(format) - 1;
|
||||
if (!*p && !chardata) {
|
||||
if (snprintf(p, sz, "%%.%df", prec) >= (int)sz)
|
||||
|
Loading…
Reference in New Issue
Block a user