Hi all,
from the --max-redirs description in the man page:
"Set this option to -1 to make it limitless."
but if --max-redirs get set to -1, curl hangs:
curl: option --max-redirs: expected a proper numerical parameter
The attached patch removes the check inside str2num() that makes it accept
only strings that start with a digit, which is wrong since strtol() supports
numbers prepended with '-' and '+' too (or spaces FWIW). Also, one can input
e.g. '0lol' and pass the check; IMO the non-NULL check is enough.
This is Debian bug #659591 [0].
Cheers
[0] http://bugs.debian.org/659591
--
perl -E'$_=q;$/= @{[@_]};and s;\S+;<inidehG ordnasselA>;eg;say~~reverse'
>From 4f0702ff1e70aadf740f03dba2a62374923ba059 Mon Sep 17 00:00:00 2001
From: Alessandro Ghedini <[email protected]>
Date: Sun, 12 Feb 2012 14:49:32 +0100
Subject: [PATCH] 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.
---
src/tool_paramhlp.c | 4 +---
1 files changed, 1 insertions(+), 3 deletions(-)
diff --git a/src/tool_paramhlp.c b/src/tool_paramhlp.c
index adb12ce..2d8e7f0 100644
--- a/src/tool_paramhlp.c
+++ b/src/tool_paramhlp.c
@@ -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))) {
--
1.7.9
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html