Re: [PATCH] ldtoa: Fix insufficient valid output digits for "%f" format.

Takashi Yano <[email protected]>
Newsgroups gmane.comp.lib.newlib
Message-ID <[email protected]>
On Thu, 25 Nov 2021 15:09:33 +0100
Corinna Vinschen wrote:
> 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 for checking. I have just submitted v2 patch fixed.


-- 
Takashi Yano <[email protected]>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.