mirror of
https://github.com/moparisthebest/curl
synced 2024-12-21 07:38:49 -05:00
Curl_timeleft: change return type to timediff_t
returning 'time_t' is problematic when that type is unsigned and we return values less than zero to signal "already expired", used in several places in the code. Closes #2021
This commit is contained in:
parent
9dfc541dd7
commit
0d85eed3df
@ -354,7 +354,7 @@ CURLcode Curl_resolver_wait_resolv(struct connectdata *conn,
|
||||
{
|
||||
CURLcode result = CURLE_OK;
|
||||
struct Curl_easy *data = conn->data;
|
||||
long timeout;
|
||||
timediff_t timeout;
|
||||
struct curltime now = Curl_now();
|
||||
struct Curl_dns_entry *temp_entry;
|
||||
|
||||
|
@ -179,12 +179,12 @@ singleipconnect(struct connectdata *conn,
|
||||
*
|
||||
* @unittest: 1303
|
||||
*/
|
||||
time_t Curl_timeleft(struct Curl_easy *data,
|
||||
timediff_t Curl_timeleft(struct Curl_easy *data,
|
||||
struct curltime *nowp,
|
||||
bool duringconnect)
|
||||
{
|
||||
int timeout_set = 0;
|
||||
time_t timeout_ms = duringconnect?DEFAULT_CONNECT_TIMEOUT:0;
|
||||
timediff_t timeout_ms = duringconnect?DEFAULT_CONNECT_TIMEOUT:0;
|
||||
struct curltime now;
|
||||
|
||||
/* if a timeout is set, use the most restrictive one */
|
||||
@ -1148,7 +1148,7 @@ CURLcode Curl_connecthost(struct connectdata *conn, /* context */
|
||||
struct curltime before = Curl_now();
|
||||
CURLcode result = CURLE_COULDNT_CONNECT;
|
||||
|
||||
time_t timeout_ms = Curl_timeleft(data, &before, TRUE);
|
||||
timediff_t timeout_ms = Curl_timeleft(data, &before, TRUE);
|
||||
|
||||
if(timeout_ms < 0) {
|
||||
/* a precaution, no need to continue if time already is up */
|
||||
|
@ -25,6 +25,7 @@
|
||||
|
||||
#include "nonblock.h" /* for curlx_nonblock(), formerly Curl_nonblock() */
|
||||
#include "sockaddr.h"
|
||||
#include "timeval.h"
|
||||
|
||||
CURLcode Curl_is_connected(struct connectdata *conn,
|
||||
int sockindex,
|
||||
@ -35,7 +36,7 @@ CURLcode Curl_connecthost(struct connectdata *conn,
|
||||
|
||||
/* generic function that returns how much time there's left to run, according
|
||||
to the timeouts set */
|
||||
time_t Curl_timeleft(struct Curl_easy *data,
|
||||
timediff_t Curl_timeleft(struct Curl_easy *data,
|
||||
struct curltime *nowp,
|
||||
bool duringconnect);
|
||||
|
||||
|
@ -333,10 +333,10 @@ static CURLcode AcceptServerConnect(struct connectdata *conn)
|
||||
* Curl_pgrsTime(..., TIMER_STARTACCEPT);
|
||||
*
|
||||
*/
|
||||
static time_t ftp_timeleft_accept(struct Curl_easy *data)
|
||||
static timediff_t ftp_timeleft_accept(struct Curl_easy *data)
|
||||
{
|
||||
time_t timeout_ms = DEFAULT_ACCEPT_TIMEOUT;
|
||||
time_t other;
|
||||
timediff_t timeout_ms = DEFAULT_ACCEPT_TIMEOUT;
|
||||
timediff_t other;
|
||||
struct curltime now;
|
||||
|
||||
if(data->set.accepttimeout > 0)
|
||||
|
@ -1318,7 +1318,7 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
|
||||
struct SingleRequest *k;
|
||||
time_t timeout_ms;
|
||||
time_t recv_timeout_ms;
|
||||
time_t send_timeout_ms;
|
||||
timediff_t send_timeout_ms;
|
||||
int control;
|
||||
|
||||
if(!GOOD_EASY_HANDLE(data))
|
||||
|
@ -57,7 +57,7 @@ int Curl_blockread_all(struct connectdata *conn, /* connection data */
|
||||
ssize_t nread;
|
||||
ssize_t allread = 0;
|
||||
int result;
|
||||
time_t timeleft;
|
||||
timediff_t timeleft;
|
||||
*n = 0;
|
||||
for(;;) {
|
||||
timeleft = Curl_timeleft(conn->data, NULL, TRUE);
|
||||
@ -382,7 +382,7 @@ CURLcode Curl_SOCKS5(const char *proxy_user,
|
||||
CURLcode code;
|
||||
curl_socket_t sock = conn->sock[sockindex];
|
||||
struct Curl_easy *data = conn->data;
|
||||
time_t timeout;
|
||||
timediff_t timeout;
|
||||
bool socks5_resolve_local =
|
||||
(conn->socks_proxy.proxytype == CURLPROXY_SOCKS5) ? TRUE : FALSE;
|
||||
const size_t hostname_len = strlen(hostname);
|
||||
|
@ -2833,7 +2833,7 @@ static CURLcode ssh_block_statemach(struct connectdata *conn,
|
||||
|
||||
while((sshc->state != SSH_STOP) && !result) {
|
||||
bool block;
|
||||
time_t left = 1000;
|
||||
timediff_t left = 1000;
|
||||
struct curltime now = Curl_now();
|
||||
|
||||
result = ssh_statemach_act(conn, &block);
|
||||
|
@ -200,7 +200,7 @@ const struct Curl_handler Curl_handler_tftp = {
|
||||
static CURLcode tftp_set_timeouts(tftp_state_data_t *state)
|
||||
{
|
||||
time_t maxtime, timeout;
|
||||
time_t timeout_ms;
|
||||
timediff_t timeout_ms;
|
||||
bool start = (state->state == TFTP_STATE_START) ? TRUE : FALSE;
|
||||
|
||||
time(&state->start_time);
|
||||
|
@ -6323,7 +6323,7 @@ static CURLcode resolve_server(struct Curl_easy *data,
|
||||
bool *async)
|
||||
{
|
||||
CURLcode result = CURLE_OK;
|
||||
time_t timeout_ms = Curl_timeleft(data, NULL, TRUE);
|
||||
timediff_t timeout_ms = Curl_timeleft(data, NULL, TRUE);
|
||||
|
||||
/*************************************************************
|
||||
* Resolve the name of the server or proxy
|
||||
|
Loading…
Reference in New Issue
Block a user