This is the mail archive of the
newlib@sourceware.org
mailing list for the newlib project.
printf field width argument handling
- From: Corinna Vinschen <vinschen at redhat dot com>
- To: newlib at sourceware dot org
- Date: Tue, 24 Nov 2009 17:44:07 +0100
- Subject: printf field width argument handling
- Reply-to: newlib at sourceware dot org
Hi,
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
--
Corinna Vinschen
Cygwin Project Co-Leader
Red Hat