1
0
mirror of https://github.com/moparisthebest/curl synced 2024-11-13 21:15:08 -05:00

lib: fix conversion warnings for SOCKET_WRITABLE/READABLE

- 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
This commit is contained in:
Jay Satiro 2020-04-07 17:18:05 -04:00
parent 17c18fbc30
commit 53f4070827
2 changed files with 6 additions and 3 deletions

View File

@ -68,7 +68,9 @@ int Curl_blockread_all(struct connectdata *conn, /* connection data */
result = CURLE_OPERATION_TIMEDOUT; result = CURLE_OPERATION_TIMEDOUT;
break; 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; result = ~CURLE_OK;
break; break;
} }

View File

@ -1645,8 +1645,9 @@ schannel_send(struct connectdata *conn, int sockindex,
written = -1; written = -1;
break; break;
} }
if(timeleft > TIME_T_MAX)
what = SOCKET_WRITABLE(conn->sock[sockindex], timeleft); timeleft = TIME_T_MAX;
what = SOCKET_WRITABLE(conn->sock[sockindex], (time_t)timeleft);
if(what < 0) { if(what < 0) {
/* fatal error */ /* fatal error */
failf(conn->data, "select/poll on SSL socket, errno: %d", SOCKERRNO); failf(conn->data, "select/poll on SSL socket, errno: %d", SOCKERRNO);