From 5657c5eaa59832bf1fa4f1e08e9ed59796ce018f Mon Sep 17 00:00:00 2001 From: Oliver Tappe Date: Wed, 21 Aug 2013 18:00:13 +0200 Subject: [PATCH] Fix #9928: broken printf specifiers "%La" and "%LA" * fix unitialized variables in __printf_fphex() in case of architectures without support for long double - this triggered unreliable results or crashes when using %La or %La on x86 * activate long double implementation in use for x86_64 for x86, too, as they share the long double format (cherry picked from commit d1716b277cbaf2b4265728d559b819d73330c1ef) --- .../posix/glibc/stdio-common/printf_fphex.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/system/libroot/posix/glibc/stdio-common/printf_fphex.c b/src/system/libroot/posix/glibc/stdio-common/printf_fphex.c index 06e0262809..271b213172 100644 --- a/src/system/libroot/posix/glibc/stdio-common/printf_fphex.c +++ b/src/system/libroot/posix/glibc/stdio-common/printf_fphex.c @@ -33,6 +33,9 @@ /* #define NDEBUG 1*/ /* Undefine this for debugging assertions. */ #include +int __printf_fphex (FILE *fp, const struct printf_info *info, + const void *const *args); + /* This defines make it possible to use the same code for GNU C library and the GNU I/O library. */ #ifdef USE_IN_LIBIO @@ -90,7 +93,7 @@ ssize_t __printf_pad __P ((FILE *, char pad, int n)); /* In vfprintf.c. */ -#ifdef __x86_64__ +#if defined(__x86_64__) || defined(__INTEL__) /* sysdeps/x86_64/fpu/printf_fphex.c */ @@ -166,7 +169,7 @@ do { \ } \ } while (0) -#endif /* __x86_64__ */ +#endif /* __x86_64__ || __INTEL__ */ int @@ -193,10 +196,10 @@ __printf_fphex (FILE *fp, /* Buffer for the generated number string for the mantissa. The maximal size for the mantissa is 128 bits. */ char numbuf[32]; - char *numstr; + char *numstr=""; char *numend; wchar_t wnumbuf[32]; - wchar_t *wnumstr; + wchar_t *wnumstr=L""; wchar_t *wnumend; int negative; @@ -205,14 +208,14 @@ __printf_fphex (FILE *fp, char *expstr; wchar_t wexpbuf[5]; wchar_t *wexpstr; - int expnegative; - int exponent; + int expnegative = 0; + int exponent = 0; /* Non-zero is mantissa is zero. */ - int zero_mantissa; + int zero_mantissa = 1; /* The leading digit before the decimal point. */ - char leading; + char leading = '0'; /* Precision. */ int precision = info->prec;