]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
lib: fix conversion warnings for SOCKET_WRITABLE/READABLE
authorJay Satiro <raysatiro@yahoo.com>
Tue, 7 Apr 2020 21:18:05 +0000 (17:18 -0400)
committerJay Satiro <raysatiro@yahoo.com>
Sat, 11 Apr 2020 06:52:25 +0000 (02:52 -0400)
- If loss of data may occur converting a timediff_t to time_t and
  the time value is > TIME_T_MAX then treat it as TIME_T_MAX.

This is a follow-up to 8843678 which removed the (time_t) typecast
from the macros so that conversion warnings could be identified.

Closes https://github.com/curl/curl/pull/5199

lib/socks.c
lib/vtls/schannel.c

index 37099130e5d2a15a62e42d114c118b3a4932383f..5dd83631c45c3e6a651c2c5389f14ad60b91329b 100644 (file)
@@ -68,7 +68,9 @@ int Curl_blockread_all(struct connectdata *conn, /* connection data */
       result = CURLE_OPERATION_TIMEDOUT;
       break;
     }
-    if(SOCKET_READABLE(sockfd, timeleft) <= 0) {
+    if(timeleft > TIME_T_MAX)
+      timeleft = TIME_T_MAX;
+    if(SOCKET_READABLE(sockfd, (time_t)timeleft) <= 0) {
       result = ~CURLE_OK;
       break;
     }
index 8bf598c07e28a75f4ae8b90fcf912f449ff4f59b..cb70d530981726f0b48e48a23cc85b450c6b2c9c 100644 (file)
@@ -1645,8 +1645,9 @@ schannel_send(struct connectdata *conn, int sockindex,
         written = -1;
         break;
       }
-
-      what = SOCKET_WRITABLE(conn->sock[sockindex], timeleft);
+      if(timeleft > TIME_T_MAX)
+        timeleft = TIME_T_MAX;
+      what = SOCKET_WRITABLE(conn->sock[sockindex], (time_t)timeleft);
       if(what < 0) {
         /* fatal error */
         failf(conn->data, "select/poll on SSL socket, errno: %d", SOCKERRNO);