tool_getparam: fix --parallel-max maximum value constraint

- Clamp --parallel-max to MAX_PARALLEL (300) instead of resetting to
  default value.

Previously, --parallel-max 300 would use 300 concurrent transfers, but
--parallel-max 301 would unexpectedly use only 50. This change clamps
higher values to the maximum (ie --parallel-max 301 would use 300).

Closes https://github.com/curl/curl/pull/8930
This commit is contained in:
JustAnotherArchivist 2022-05-28 05:07:02 +00:00 committed by Jay Satiro
parent f51ffdb35f
commit 10cd69623a

View File

@ -2337,8 +2337,9 @@ ParameterError getparameter(const char *flag, /* f or -long-flag */
err = str2unum(&global->parallel_max, nextarg);
if(err)
return err;
if((global->parallel_max > MAX_PARALLEL) ||
(global->parallel_max < 1))
if(global->parallel_max > MAX_PARALLEL)
global->parallel_max = MAX_PARALLEL;
else if(global->parallel_max < 1)
global->parallel_max = PARALLEL_DEFAULT;
break;
case 'c': /* --parallel-connect */