public inbox for newlib@sourceware.org
 help / color / mirror / Atom feed
From: Corinna Vinschen <vinschen@redhat.com>
To: newlib@sourceware.org
Subject: Re: [PATCH] ldtoa: Fix insufficient valid output digits for "%f" format.
Date: Thu, 25 Nov 2021 15:09:33 +0100	[thread overview]
Message-ID: <YZ+ZHZ3jWNwNgePx@calimero.vinschen.de> (raw)
In-Reply-To: <20211125120207.258-1-takashi.yano@nifty.ne.jp>

Hi Takashi,

looks good, but I see a potential problem at one point:

On Nov 25 21:02, Takashi Yano wrote:
> +   limit now, either ndec (<= NDEC) or NDEC_SML, depending on ndigits. */
> +  int ndec;
> +  if (mode == 3) /* %f */
> +    {
> +      int expon = (e[NE - 1] & 0x7fff) - (EXONE - 1); /* exponent part */
> +      /* log2(10) approximately 485/146 */
> +      ndec = expon * 146 / 485 + ndigits;

We have targets with sizeof(int) == 2.  If expon is any number up to
0x7fff, multiplying it with 146 will overflow.  Using __int32_t for
expon should be safer.


Thanks,
Corinna


  reply	other threads:[~2021-11-25 14:09 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-25 12:02 Takashi Yano
2021-11-25 14:09 ` Corinna Vinschen [this message]
2021-11-25 21:51   ` Takashi Yano

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=YZ+ZHZ3jWNwNgePx@calimero.vinschen.de \
    --to=vinschen@redhat.com \
    --cc=newlib@sourceware.org \
    /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).