[uClibc]here's a new version of strtod

David Schleef ds at schleef.org
Tue Dec 12 20:08:11 UTC 2000


On Tue, Dec 12, 2000 at 10:27:29AM -0700, Erik Andersen wrote:
> On Mon Dec 11, 2000 at 05:58:05PM -0600, Manuel Novoa III wrote:
> > 
> > Erik,
> > 
> > Here's an implementation of strtod, along with one support routine.
> > Compiling with -Os -fomit-frame-pointer for i386, I get the sizes
> > (for all data = 0, bss = 0) for the text section for various selections
> > of compile-time options:
> > 
> >   270  current version converted to doubles + 2 bugs fixed
> >   227  above, but uses isdigit macro and switch for sign
> > 
> >   219  new strtod (stripped-down) version included below
> >   222  above + RESTRICT_EXP (prevents exponent overflow)
> >   299  above + WANT_ENDPTR (handles endptr properly)
> >   317  above + RESTRICT_DIGITS (smarter mantissa processing)
> >   329  above + LOG_SCALING (smarter scaling)
> >   389  above + STRTOD_ERRNO (sets errno - needs zoicheck.o)
> >    45  zoicheck.o (needed for errno support)
> > 
> >   268  new strtod + RESTRICT_EXP + RESTRICT_DIGITS
> >   281  above + LOG_SCALING
> 
> This is pretty slick.  I like it.  :-)
> 

I get a funny feeling about it.  It's not a very rational
feeling, but it basically comes down to standards compliance.
I'm just happy to have a well-crafted _small_, non-bloated
library, not to be able to configure it down to strange
behavior.  I doubt that many people will want to disable
STRTOD_ERRNO, because they don't _know_ that some section
of their code won't use it in an extraordinary situation.

The other problem I have is that strtod is often parsing
non-verified input, which leads to the possibility of
security problems in certain applications.  It is, of
course, possible to verify many of the common cases of
a stripped-down strtod(), but _I_ would not want to
write it.

Like I said, funny feeling, not dislike.



dave...






More information about the uClibc mailing list