core-util: Make number parsing stricter

System Internals / PulseAudio - Tanu Kaskinen [] - 16 March 2015 11:52 UTC

pa_atou(), pa_atol() and pa_atod() are stricter than the libc counterparts (the PA functions reject strings that have trailing extra stuff in them). I have been under the impression that the PA functions only accept "obviously valid numbers", that is, I have assumed that these would be rejected: " 42" (leading whitespace), "" (empty string) and "-18446744073709551615" in case of pa_atou().

I noticed that empty strings are accepted, however, and on closer inspection I found that leading whitespace is accepted too, and even that pa_atou() thinks that "-18446744073709551615" is the same thing as "1"! This patch makes the parsing functions more strict, so that they indeed only accept "obviously valid numbers". I decided to also disallow leading plus signs, just because I don't like them.

c0ab9e6 core-util: Make number parsing stricter
src/pulsecore/core-util.c | 55 ++++++++++++++++++++++++++++++++++++++++++---
1 file changed, 52 insertions(+), 3 deletions(-)


  • Share