aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2005-11-13 11:06:48 +0000
committerDaniel Stenberg <daniel@haxx.se>2005-11-13 11:06:48 +0000
commitadf462fe0508e7229bcfabfd8ae7012aa57e5066 (patch)
treee8f759b34f7e626225c9baef4c5cc71d1584bc97 /src
parentc2862742abc76440657190a02a1e92be1e2c01f1 (diff)
Debian bug report 338681 by Jan Kunder: make curl better detect and report bad
limit-rate units: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=338681 Now curl will return error if a bad unit is used.
Diffstat (limited to 'src')
-rw-r--r--src/main.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/main.c b/src/main.c
index 99edc61d7..c43241930 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1497,7 +1497,11 @@ static ParameterError getparameter(char *flag, /* f or -long-flag */
/* We support G, M, K too */
char *unit;
curl_off_t value = curlx_strtoofft(nextarg, &unit, 0);
- switch(nextarg[strlen(nextarg)-1]) {
+
+ if(strlen(unit) != 1)
+ unit="w"; /* unsupported */
+
+ switch(*unit) {
case 'G':
case 'g':
value *= 1024*1024*1024;
@@ -1510,6 +1514,13 @@ static ParameterError getparameter(char *flag, /* f or -long-flag */
case 'k':
value *= 1024;
break;
+ case 'b':
+ case 'B':
+ /* for plain bytes, leave as-is */
+ break;
+ default:
+ warnf(config, "unsupported rate unit. Use G, M, K or B!\n");
+ return PARAM_BAD_USE;
}
config->recvpersecond = value;
config->sendpersecond = value;