This is the mail archive of the newlib@sources.redhat.com mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [RFA] strtod: Fix sign bug if exponent is invalid (was Re: [cw@gamma-rs.ch: error in scanf reading %le format and 00 exponent])


On Mar 31 15:59, Jeff Johnston wrote:
> Corinna Vinschen wrote:
> >The below patch only fixes _strtod_r, since that's sufficient to solve
> >the problem.
> >
> >However, a full solution also changes __svfscanf_r so that a 0 exponent
> >is correctly copied to buf.  Right now, I don't see how to do this
> >elegantly.  In theory it requires another value in the `flags' variable
> >AFAICS.
> >
> 
> Thanks for catching this Corinna.  Please check it in.  There is no need to 
> post a fix in vfscanf.  The reason is that if the exponent is 0, then 
> strtod or strtold stopping processing at that point is still correct.  
> vscanf has already preparsed and verified the input string; it does use the 
> endptr so it doesn't matter that it gets set to the unprocessed exponent.

Thanks, applied.  However, even though the patch to vfscanf is not
necessary, I think it would be more correct.  It looks fairly fragile
to me, to rely on strtod doing the "right thing" with an invalid
expression.  Again:  __svfscanf_r creates an *invalid* expression.
If, for any reason, the implementation of strtod is changed, or the
target has a non-newlib implementation of strtod, the wrong behaviour 
of __svfscanf_r might provoke new problems in future.  I don't think
that's the way to go.


Corinna

-- 
Corinna Vinschen
Cygwin Project Co-Leader
Red Hat, Inc.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]