Commit f5005dd8 authored by Dave Reisner's avatar Dave Reisner Committed by Daniel Stenberg
Browse files

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.
parent d3aaa68f
Loading
Loading
Loading
Loading
+7 −3
Original line number Diff line number Diff line
@@ -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;
}

/*