-
Notifications
You must be signed in to change notification settings - Fork 141
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
strtod
might be unsafe on some systems
#61
Comments
Could we copy an existing implementation from one of the many libs around? |
@frink , You're probably right. Finding a good implementation with an MIT license and integrating it is would probably be the most effective approach - especially if we could use the However, there's a couple of reasons I'm holding off on that:
Having said that, adding a task to the makefile, like the one for BearSSL, would be a great solution. |
strtod
should be considered unsafestrtod
might be unsafe on some systems
Musl is MIT. Don't know if it supports binary representations or not... This one is public domain but may need a little finesse: |
Thanks for taking the time to find a solution. Lets put this one on low priority, there's a bunch of stuff that uses I think BearSSL would be more important than this side-detail. Also...
In addition, |
Correction: I was looking at the public domain implementation. The Musl library might be a good option for an |
Good dea! |
facil.io protects the JSON parser and Strings from overflowing during a call to
strtod
... however, it still appears thatstrtod
callsstrlen
internally on some systems.One might have assumed the issue was fixed... however, using my profiler showed distinct calls make from
strtod
tostrlen
on some systems (and I hope it was some sort of mistake).This isn't really safe if the string isn't NUL terminated.
It also wastes CPU cycles when the floating point number is in the middle (rather than the end) of a string.
Rolling an
strtod
alternative (or copying the buffer to a NUL terminated buffer before parsing the data), should be considered.It is currently recommended that developers test the
strtod
implementations and consider overriding the function using safe implementations (when discovering an issue).The text was updated successfully, but these errors were encountered: