diff options
author | Michael Deutschmann <michael@talamasca.ocis.net> | 2010-03-17 13:36:34 +0100 |
---|---|---|
committer | Bernhard Reutner-Fischer <rep.dot.nop@gmail.com> | 2010-03-17 14:54:04 +0100 |
commit | 266aaaf46e136d63532a797fd8604e30d4350443 (patch) | |
tree | 94659829fce08a15ba5895651ab42530dab431d1 /libc/stdio | |
parent | 919d99c7c00655a0376ed0ba0f22b1bba7510583 (diff) |
lift printf field width limit
uClibc mishandles printf field width limits larger than 40959, as a
result of misguided overflow-protection code. This causes spurious test
failures with GNU coreutils, which depends on "%65536s" and "%20000000f"
working according to spec.
Signed-off-by: Michael Deutschmann <michael@talamasca.ocis.net>
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
Diffstat (limited to 'libc/stdio')
-rw-r--r-- | libc/stdio/_vfprintf.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/libc/stdio/_vfprintf.c b/libc/stdio/_vfprintf.c index f288cb501..6fa8ecb8d 100644 --- a/libc/stdio/_vfprintf.c +++ b/libc/stdio/_vfprintf.c @@ -161,9 +161,6 @@ /* Now controlled by uClibc_stdio.h. */ /* #define __UCLIBC_HAS_GLIBC_CUSTOM_PRINTF__ */ -/* TODO -- move these to a configuration section? */ -#define MAX_FIELD_WIDTH 4095 - #ifdef __UCLIBC_MJN3_ONLY__ #ifdef L_register_printf_function /* emit only once */ @@ -893,8 +890,11 @@ int attribute_hidden _ppfs_parsespec(ppfs_t *ppfs) } i = 0; while (isdigit(*fmt)) { - if (i < MAX_FIELD_WIDTH) { /* Avoid overflow. */ + if (i < INT_MAX / 10 + || (i == INT_MAX / 10 && (*fmt - '0') <= INT_MAX % 10)) { i = (i * 10) + (*fmt - '0'); + } else { + i = INT_MAX; /* best we can do... */ } ++fmt; } |