Skip to content
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

Buffer overflow possible with d2fixed() and friends #197

Open
paulharris opened this issue Apr 4, 2021 · 0 comments
Open

Buffer overflow possible with d2fixed() and friends #197

paulharris opened this issue Apr 4, 2021 · 0 comments

Comments

@paulharris
Copy link

paulharris commented Apr 4, 2021

Hi,

I know there are several other issues open on this related topic,
but I believe this would be slightly solution - hard fail please,

This bit of code will cause ryu to overflow its buffer:
d2fixed(1.0, 5000);
d2exp() will also do this,
both allocate a buffer = malloc(2000)
and then will blindly write as many characters as demanded by the precision parameter.

In my example requests 5000 precision, and ryu will try and write 5003 characters into the 2000 byte buffers.

I think you could set a hard max precision allowed, and abort() or fail or whatever.
Anything would be better than overflowing the buffer!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant