[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnurl] 244/264: select: make Curl_socket_check take timediff_t timeout
From: |
gnunet |
Subject: |
[gnurl] 244/264: select: make Curl_socket_check take timediff_t timeout |
Date: |
Thu, 30 Apr 2020 16:09:07 +0200 |
This is an automated email from the git hooks/post-receive script.
nikita pushed a commit to branch master
in repository gnurl.
commit a96c7529eb31498a464910935a7d1a5e88ce3914
Author: Daniel Stenberg <address@hidden>
AuthorDate: Wed Apr 15 10:27:20 2020 +0200
select: make Curl_socket_check take timediff_t timeout
Coverity found CID 1461718:
Integer handling issues (CONSTANT_EXPRESSION_RESULT) "timeout_ms >
9223372036854775807L" is always false regardless of the values of its
operands. This occurs as the logical second operand of "||".
Closes #5240
---
lib/gopher.c | 6 +++---
lib/select.c | 4 ++--
lib/select.h | 2 +-
lib/socks.c | 4 ++--
lib/vtls/schannel.c | 6 +++---
5 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/lib/gopher.c b/lib/gopher.c
index 4216e6136..c48098f75 100644
--- a/lib/gopher.c
+++ b/lib/gopher.c
@@ -147,8 +147,8 @@ static CURLcode gopher_do(struct connectdata *conn, bool
*done)
result = CURLE_OPERATION_TIMEDOUT;
break;
}
- if(!timeout_ms || timeout_ms > TIME_T_MAX)
- timeout_ms = TIME_T_MAX;
+ if(!timeout_ms)
+ timeout_ms = TIMEDIFF_T_MAX;
/* Don't busyloop. The entire loop thing is a work-around as it causes a
BLOCKING behavior which is a NO-NO. This function should rather be
@@ -156,7 +156,7 @@ static CURLcode gopher_do(struct connectdata *conn, bool
*done)
possible to send now will be sent in the doing function repeatedly
until the entire request is sent.
*/
- what = SOCKET_WRITABLE(sockfd, (time_t)timeout_ms);
+ what = SOCKET_WRITABLE(sockfd, timeout_ms);
if(what < 0) {
result = CURLE_SEND_ERROR;
break;
diff --git a/lib/select.c b/lib/select.c
index 857e7f698..d91b20a4b 100644
--- a/lib/select.c
+++ b/lib/select.c
@@ -201,7 +201,7 @@ int Curl_select(curl_socket_t maxfd,
int Curl_socket_check(curl_socket_t readfd0, /* two sockets to read from */
curl_socket_t readfd1,
curl_socket_t writefd, /* socket to write to */
- time_t timeout_ms) /* milliseconds to wait */
+ timediff_t timeout_ms) /* milliseconds to wait */
{
#ifdef HAVE_POLL_FINE
struct pollfd pfd[3];
@@ -333,7 +333,7 @@ int Curl_socket_check(curl_socket_t readfd0, /* two sockets
to read from */
curl_socket_t is unsigned in such cases and thus -1 is the largest
value).
*/
- r = Curl_select(maxfd, &fds_read, &fds_write, &fds_err, timeout_ms);
+ r = Curl_select(maxfd, &fds_read, &fds_write, &fds_err, (time_t)timeout_ms);
if(r < 0)
return -1;
diff --git a/lib/select.h b/lib/select.h
index 2667d0ccf..0fd8ed515 100644
--- a/lib/select.h
+++ b/lib/select.h
@@ -80,7 +80,7 @@ int Curl_select(curl_socket_t maxfd,
int Curl_socket_check(curl_socket_t readfd, curl_socket_t readfd2,
curl_socket_t writefd,
- time_t timeout_ms);
+ timediff_t timeout_ms);
#define SOCKET_READABLE(x,z) \
Curl_socket_check(x, CURL_SOCKET_BAD, CURL_SOCKET_BAD, z)
#define SOCKET_WRITABLE(x,z) \
diff --git a/lib/socks.c b/lib/socks.c
index dfd944ef3..18affbc96 100644
--- a/lib/socks.c
+++ b/lib/socks.c
@@ -68,9 +68,9 @@ int Curl_blockread_all(struct connectdata *conn, /*
connection data */
result = CURLE_OPERATION_TIMEDOUT;
break;
}
- if(!timeout_ms || timeout_ms > TIME_T_MAX)
+ if(!timeout_ms)
timeout_ms = TIME_T_MAX;
- if(SOCKET_READABLE(sockfd, (time_t)timeout_ms) <= 0) {
+ if(SOCKET_READABLE(sockfd, timeout_ms) <= 0) {
result = ~CURLE_OK;
break;
}
diff --git a/lib/vtls/schannel.c b/lib/vtls/schannel.c
index dce6242da..49659bb7a 100644
--- a/lib/vtls/schannel.c
+++ b/lib/vtls/schannel.c
@@ -1645,9 +1645,9 @@ schannel_send(struct connectdata *conn, int sockindex,
written = -1;
break;
}
- if(!timeout_ms || timeout_ms > TIME_T_MAX)
- timeout_ms = TIME_T_MAX;
- what = SOCKET_WRITABLE(conn->sock[sockindex], (time_t)timeout_ms);
+ if(!timeout_ms)
+ timeout_ms = TIMEDIFF_T_MAX;
+ what = SOCKET_WRITABLE(conn->sock[sockindex], timeout_ms);
if(what < 0) {
/* fatal error */
failf(conn->data, "select/poll on SSL socket, errno: %d", SOCKERRNO);
--
To stop receiving notification emails like this one, please contact
address@hidden.
- [gnurl] 263/264: Merge tag 'curl-7_70_0', (continued)
- [gnurl] 263/264: Merge tag 'curl-7_70_0', gnunet, 2020/04/30
- [gnurl] 196/264: scripts/release-notes.pl: accept colon after the Fixes/Closes keywords, gnunet, 2020/04/30
- [gnurl] 169/264: tests/server: add CTRL event handler for Win32 consoles, gnunet, 2020/04/30
- [gnurl] 243/264: libcurl-multi.3: added missing full stop, gnunet, 2020/04/30
- [gnurl] 209/264: tests: move pingpong server to dynamic listening port, gnunet, 2020/04/30
- [gnurl] 184/264: tests: add the mqtt test server mqttd, gnunet, 2020/04/30
- [gnurl] 210/264: test1028: make it run on dynamic FTP server port, gnunet, 2020/04/30
- [gnurl] 211/264: test1055: make it work with dynamic FTP port, gnunet, 2020/04/30
- [gnurl] 176/264: appveyor: completely disable tests that fail to timeout early, gnunet, 2020/04/30
- [gnurl] 139/264: release-notes: output trailing references sorted numerically, gnunet, 2020/04/30
- [gnurl] 244/264: select: make Curl_socket_check take timediff_t timeout,
gnunet <=
- [gnurl] 150/264: release-notes: fix the initial reference list output, gnunet, 2020/04/30
- [gnurl] 144/264: http: allow Curl_add_buffer_send() to do a short first send by force, gnunet, 2020/04/30
- [gnurl] 262/264: RELEASE-NOTES: 7.70.0, gnunet, 2020/04/30
- [gnurl] 159/264: lib: fix conversion warnings for SOCKET_WRITABLE/READABLE, gnunet, 2020/04/30
- [gnurl] 182/264: mqtt: add new experimental protocol, gnunet, 2020/04/30
- [gnurl] 145/264: http: don't consider upload done if the request isn't completely sent off, gnunet, 2020/04/30
- [gnurl] 181/264: TODO: Consider convenience options for JSON and XML?, gnunet, 2020/04/30
- [gnurl] 143/264: connect: store connection info for QUIC connections, gnunet, 2020/04/30
- [gnurl] 148/264: runtests: provide nicer errormsg when protocol "dump" file is empty, gnunet, 2020/04/30
- [gnurl] 258/264: nss: check for PK11_CreateDigestContext() returning NULL, gnunet, 2020/04/30