smb: avoid integer overflow on weird input date

Found by OSS-fuzz

Closes #17206
This commit is contained in:
Daniel Stenberg 2025-04-28 13:35:02 +02:00
parent 1589898b4a
commit 771c15b603
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2

View file

@ -926,16 +926,20 @@ static CURLcode smb_connection_state(struct Curl_easy *data, bool *done)
*/
static void get_posix_time(time_t *out, curl_off_t timestamp)
{
timestamp -= CURL_OFF_T_C(116444736000000000);
timestamp /= 10000000;
if(timestamp >= CURL_OFF_T_C(116444736000000000)) {
timestamp -= CURL_OFF_T_C(116444736000000000);
timestamp /= 10000000;
#if SIZEOF_TIME_T < SIZEOF_CURL_OFF_T
if(timestamp > TIME_T_MAX)
*out = TIME_T_MAX;
else if(timestamp < TIME_T_MIN)
*out = TIME_T_MIN;
else
if(timestamp > TIME_T_MAX)
*out = TIME_T_MAX;
else if(timestamp < TIME_T_MIN)
*out = TIME_T_MIN;
else
#endif
*out = (time_t) timestamp;
*out = (time_t) timestamp;
}
else
*out = 0;
}
static CURLcode smb_request_state(struct Curl_easy *data, bool *done)