pugixml icon indicating copy to clipboard operation
pugixml copied to clipboard

Integer/floating point parsing should validate content and/or value range

Open zeux opened this issue 11 years ago • 2 comments
trafficstars

This issue was filed on Google Code: https://code.google.com/p/pugixml/issues/detail?id=237

There are concerns about using errno on some platforms; even on platforms that have MT-safe errno, parsing denormal numbers will set errno to ERANGE but keep the parsed output as far as I know.

Checking the end pointer can potentially be a breaking change if applications relied on parsing numbers like "1.2f".

zeux avatar Oct 26 '14 09:10 zeux

Additional note: for parsing unsigned integers, ERANGE will not be set for negative numbers when using strtoul/strtoull - so we'll have to check whether there is a whitespace + minus sequence and flag this as invalid.

zeux avatar Dec 14 '14 17:12 zeux

New integer parsing implementation handles overflow/underflow correctly for all cases. It still uses the legacy way of clamping the result without indicating an error, but at least for integers it's now easy to implement full validation - the open question being the specific interface.

zeux avatar Oct 19 '15 16:10 zeux