]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
ws: fix type conversion check
authorJay Satiro <raysatiro@yahoo.com>
Sun, 12 Oct 2025 22:35:22 +0000 (18:35 -0400)
committerJay Satiro <raysatiro@yahoo.com>
Tue, 14 Oct 2025 15:06:49 +0000 (11:06 -0400)
- Fix logic that checks whether a size_t will fit in a curl_off_t.

Reported-by: Viktor Szakats
Fixes https://github.com/curl/curl/issues/19017
Closes https://github.com/curl/curl/pull/19036

lib/ws.c

index 6c8f07e1776e18aacc02e02af0205d1b26fe245d..ec79235550301ad9dba8beba1bb521766fb8d2b0 100644 (file)
--- a/lib/ws.c
+++ b/lib/ws.c
@@ -654,8 +654,8 @@ static curl_off_t ws_payload_remain(curl_off_t payload_total,
   curl_off_t remain = payload_total - payload_offset;
   if((payload_total < 0) || (payload_offset < 0) || (remain < 0))
     return -1;
-#if SIZEOF_OFF_T <= SIZEOF_SIZE_T
-  if((curl_off_t)payload_buffered < 0)
+#if SIZEOF_SIZE_T >= SIZEOF_CURL_OFF_T
+  if(payload_buffered > (size_t)CURL_OFF_T_MAX)
     return -1;
 #endif
   if(remain < (curl_off_t)payload_buffered)