multi: cap expire times to INT_MAX internally

When the time-out value is passed to the outside world it needs to fit
in a signed 32-bit variable (on Windows and 32-bit architectures)
anyway. Also, this is 3.5 weeks and we should not knowingly set timeouts
that long anyway.

The previous cap introduced in 3089e7eec8 was only partial.

Closes #22579
This commit is contained in:
Daniel Stenberg 2026-08-14 09:48:46 +02:00
parent e825e55867
commit a3aaca10d9
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2

View file

@ -3757,6 +3757,11 @@ void Curl_expire_ex(struct Curl_easy *data,
if(!multi)
return;
DEBUGASSERT(eid < EXPIRE_LAST);
DEBUGASSERT(milli <= INT_MAX);
if(milli > INT_MAX)
/* Cap ridiculous timeouts, 31-bit ms is still 3.5 weeks. When the time
goes to the user, it must fit in this size. */
milli = INT_MAX;
set = *Curl_pgrs_now(data);
set.tv_sec += (time_t)(milli / 1000); /* may be a 64 to 32-bit conversion */