mirror of
https://github.com/curl/curl.git
synced 2025-03-19 15:40:42 +08:00
src/tool_paramhlp: try harder to catch negatives
strto* functions happily chomp off leading whitespace, so simply checking for str[0] can lead to false negatives. Do the full parse and check the out value instead.
This commit is contained in:
parent
d3aaa68f55
commit
f5005dd8d0
@ -178,9 +178,13 @@ ParameterError str2num(long *val, const char *str)
|
||||
|
||||
ParameterError str2unum(long *val, const char *str)
|
||||
{
|
||||
if(str[0]=='-')
|
||||
return PARAM_NEGATIVE_NUMERIC; /* badness */
|
||||
return str2num(val, str);
|
||||
ParameterError result = str2num(val, str);
|
||||
if(result != PARAM_OK)
|
||||
return result;
|
||||
if(*val < 0)
|
||||
return PARAM_NEGATIVE_NUMERIC;
|
||||
|
||||
return PARAM_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
|
Loading…
x
Reference in New Issue
Block a user