1
0
mirror of https://github.com/moparisthebest/curl synced 2024-12-22 16:18:48 -05:00

curl tool: allow negative numbers as option values

Fix the str2num() function to not check if the input string starts with a
digit, since strtol() supports numbers prepended with '-' (and '+') too.
This makes the --max-redirs option work as documented.
This commit is contained in:
Alessandro Ghedini 2012-02-12 14:49:32 +01:00 committed by Daniel Stenberg
parent 7ed25fcc5c
commit e71ac0c6fa

View File

@ -151,8 +151,6 @@ void cleanarg(char *str)
* Parse the string and write the integer in the given address. Return
* non-zero on failure, zero on success.
*
* The string must start with a digit to be valid.
*
* Since this function gets called with the 'nextarg' pointer from within the
* getparameter a lot, we must check it for NULL before accessing the str
* data.
@ -160,7 +158,7 @@ void cleanarg(char *str)
int str2num(long *val, const char *str)
{
if(str && ISDIGIT(*str)) {
if(str) {
char *endptr;
long num = strtol(str, &endptr, 10);
if((endptr != str) && (endptr == str + strlen(str))) {