tool_paramhlp: avoid integer overflow in secs2ms()

The previous approach was wrong and could lead to wrong timeout values
getting used.

Reported-by: bsr13 on hackerone
Closes #17184
This commit is contained in:
Daniel Stenberg 2025-04-25 12:05:52 +02:00
parent cc884c08a8
commit 4db64a6437
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
3 changed files with 37 additions and 2 deletions

View file

@ -328,7 +328,7 @@ ParameterError secs2ms(long *valp, const char *str)
const unsigned int digs[] = { 1, 10, 100, 1000, 10000, 1000000,
1000000, 10000000, 100000000 };
if(!str ||
curlx_str_number(&str, &secs, CURL_OFF_T_MAX/100))
curlx_str_number(&str, &secs, LONG_MAX/1000 - 1))
return PARAM_BAD_NUMERIC;
if(!curlx_str_single(&str, '.')) {
curl_off_t fracs;