From: Jakub Jelinek <jakub@redhat.com>
To: Ulrich Drepper <drepper@redhat.com>
Cc: Glibc hackers <libc-hacker@sources.redhat.com>
Subject: [PATCH] Fix __printf_fp
Date: Wed, 24 Mar 2004 15:31:00 -0000 [thread overview]
Message-ID: <20040324095017.GJ15946@sunsite.ms.mff.cuni.cz> (raw)
Hi!
For IEEE quad long double with BITS_PER_MP_LIMB 32, mantissa takes exactly
4 limbs. Until now any mantissa took at most 2 limbs (either IEEE extended
long double on 32-bit arch or IEEE quad on 64-bit arch) and bignum_size
reserved at least twice as many limbs for extra operations (e.g. it
does frac[fracsize++] = cy; in certain cases etc.).
Without this printf with certain numbers results in buffer overflows.
2004-03-24 Jakub Jelinek <jakub@redhat.com>
* stdio-common/printf_fp.c (__printf_fp): For IEEE quad long double
on 32-bit architectures reserve 8 limbs instead of 4.
--- libc/stdio-common/printf_fp.c.jj 2004-03-23 12:28:47.000000000 -0500
+++ libc/stdio-common/printf_fp.c 2004-03-24 11:01:38.000000000 -0500
@@ -431,7 +431,9 @@ __printf_fp (FILE *fp,
would be really big it could lead to memory problems. */
{
mp_size_t bignum_size = ((ABS (exponent) + BITS_PER_MP_LIMB - 1)
- / BITS_PER_MP_LIMB + 4) * sizeof (mp_limb_t);
+ / BITS_PER_MP_LIMB
+ + (LDBL_MANT_DIG / BITS_PER_MP_LIMB > 2 ? 8 : 4))
+ * sizeof (mp_limb_t);
frac = (mp_limb_t *) alloca (bignum_size);
tmp = (mp_limb_t *) alloca (bignum_size);
scale = (mp_limb_t *) alloca (bignum_size);
Jakub
next reply other threads:[~2004-03-24 12:00 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-03-24 15:31 Jakub Jelinek [this message]
2004-03-26 9:23 ` Ulrich Drepper
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20040324095017.GJ15946@sunsite.ms.mff.cuni.cz \
--to=jakub@redhat.com \
--cc=drepper@redhat.com \
--cc=libc-hacker@sources.redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).