Closed MakotoE closed 2 years ago
Nice find and great to have this fix!
But I think 180ms is far too long for most applications. If I'm not mistaken, the age of the universe is about 1e20 seconds, so do we really need 1e1000000?
I'm closing this PR because the suggestions in the linked issue are better.
This changes
parse()
to quickly return an error if the exponent is very large. It addresses a potential denial-of-service vulnerability.I did a fuzz test and found a string that can cause it to hang. This case timed out after 1785 seconds.
Doing
parse("1e1000000s")
, the highest possible exponent as a result of this change, takes 180 milliseconds on an optimized build. Adding another zero takes 6 seconds.