]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
vquic/ngtcp2: compare idle timeout in ms to avoid overflow
authorJoshua Rogers <MegaManSec@users.noreply.github.com>
Tue, 7 Oct 2025 07:48:36 +0000 (15:48 +0800)
committerDaniel Stenberg <daniel@haxx.se>
Tue, 7 Oct 2025 10:06:32 +0000 (12:06 +0200)
Closes #18903

lib/vquic/curl_ngtcp2.c
lib/vquic/curl_osslq.c

index 9851a087c1b14ec2f97425a9dbba1d1f2cd7ab85..af7f26eb3988028a5fdabcbf74ab14203861c0af 100644 (file)
@@ -2745,9 +2745,12 @@ static bool cf_ngtcp2_conn_is_alive(struct Curl_cfilter *cf,
   rp = ngtcp2_conn_get_remote_transport_params(ctx->qconn);
   if(rp && rp->max_idle_timeout) {
     timediff_t idletime_ms = curlx_timediff(curlx_now(), ctx->q.last_io);
-    if(idletime_ms > 0 &&
-      ((uint64_t)idletime_ms * NGTCP2_MILLISECONDS) > rp->max_idle_timeout)
-      goto out;
+    if(idletime_ms > 0) {
+      uint64_t max_idle_ms =
+        (uint64_t)(rp->max_idle_timeout / NGTCP2_MILLISECONDS);
+      if((uint64_t)idletime_ms > max_idle_ms)
+        goto out;
+    }
   }
 
   if(!cf->next || !cf->next->cft->is_alive(cf->next, data, input_pending))
index 474ed595cb66597e22e725f6eef179485ae326db..3fd2daf92fbd0f381a2c0e52a2fc810852fea08d 100644 (file)
@@ -2254,8 +2254,8 @@ static bool cf_osslq_conn_is_alive(struct Curl_cfilter *cf,
     CURL_TRC_CF(data, cf, "negotiated idle timeout: %" FMT_PRIu64 "ms",
                 (curl_uint64_t)idle_ms);
     idletime = curlx_timediff(curlx_now(), ctx->q.last_io);
-    if(idle_ms != 0 && idletime > 0 && (uint64_t)idletime > idle_ms)
-       goto out;
+    if(idle_ms && idletime > 0 && (uint64_t)idletime > idle_ms)
+      goto out;
   }
 
 #endif