aboutsummaryrefslogtreecommitdiff
path: root/src/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.c')
-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;