[pulseaudio-discuss] [PATCH] core-util: Make number parsing stricter

Tanu Kaskinen tanu.kaskinen at linux.intel.com
Mon Mar 16 09:56:44 PDT 2015


On Thu, 2015-02-26 at 22:02 +0100, Peter Meerwald wrote:
> Hello,
> 
> > 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". In case of
> > pa_atou() I decided to also disallow a leading plus sign, as it's
> > redundant, and looks very strange (i.e. not obviously valid) in
> > contexts where the number represents, for example, an array index.
> 
> looks good
> 
> pa_atol() and pa_atod() could reject a leading '+'

Thanks, I pushed the patch now. I incorporated your suggestion.

-- 
Tanu



More information about the pulseaudio-discuss mailing list