printf field width argument handling

Corinna Vinschen
Tue Nov 24 19:32:00 GMT 2009


better don't try this on your machine:

  printf ("%*********s", 6, "abc");

It's an almost sure way to let the CPU run away.  Yes, it's a malformed
format string.  But still, instead of bailing out early, every single
'*' will result in reading the next argument from the argument list to
fetch the field width.  The same occurs for precision specifiers.

It does not occur in glibc, though.  So my question is this.  Shouldn't
we avoid to do that and stop converting further arguments into width and
precision values after the first '*' has been handled?  And if so, what
would be the most useful error reaction?


Corinna Vinschen
Cygwin Project Co-Leader
Red Hat

More information about the Newlib mailing list