akheron / jansson

C library for encoding, decoding and manipulating JSON data
http://www.digip.org/jansson/
Other
3.05k stars 809 forks source link

jsonp_strtod: return -1 on Infinity or NaN #582

Closed guijan closed 3 years ago

guijan commented 3 years ago

strtod() also looks for the strings "INF" or "NAN" and returns Infinity or NaN respectively, both are explicitly forbidden by the RFC.

coveralls commented 3 years ago

Coverage Status

Coverage decreased (-0.04%) to 96.121% when pulling 69a0f881b21b452afd9b1db9e113a58c01f9c901 on guijan:no-infinity-or-nan into 0dffb4284e7872c6e26956ad85fe127ba77220dc on akheron:master.

akheron commented 3 years ago

Thanks! Would you mind adding a test that demonstrates the case this change fixes? Also, it seems that this doesn’t compile on older Visual Studio versions, which has to be worked around somehow.

guijan commented 3 years ago

I'm sorry for the trouble, but I only realized now the parser detects a syntax error in the JSON before strtod gets to convert such a string.