From 22cfeac730d5b115b04f6b6ebf2f0a74f0bc978d Mon Sep 17 00:00:00 2001 From: Jay Satiro Date: Sat, 17 Sep 2016 01:48:20 -0400 Subject: easy: Reset all statistical session info in curl_easy_reset Bug: https://github.com/curl/curl/issues/1017 Reported-by: Jeroen Ooms --- lib/easy.c | 3 +++ lib/getinfo.c | 19 ++++++++++++++----- lib/urldata.h | 1 + 3 files changed, 18 insertions(+), 5 deletions(-) (limited to 'lib') diff --git a/lib/easy.c b/lib/easy.c index 583de154b..08adf6d24 100644 --- a/lib/easy.c +++ b/lib/easy.c @@ -995,6 +995,9 @@ void curl_easy_reset(struct Curl_easy *data) /* zero out Progress data: */ memset(&data->progress, 0, sizeof(struct Progress)); + /* zero out PureInfo data: */ + Curl_initinfo(data); + data->progress.flags |= PGRS_HIDE; data->state.current_speed = -1; /* init to negative == impossible */ } diff --git a/lib/getinfo.c b/lib/getinfo.c index 262cd934f..9641d79dc 100644 --- a/lib/getinfo.c +++ b/lib/getinfo.c @@ -36,8 +36,8 @@ #include "memdebug.h" /* - * This is supposed to be called in the beginning of a perform() session - * and should reset all session-info variables + * This is supposed to be called in the beginning of a perform() session and + * in curl_easy_reset() and should reset all session-info variables. */ CURLcode Curl_initinfo(struct Curl_easy *data) { @@ -58,18 +58,27 @@ CURLcode Curl_initinfo(struct Curl_easy *data) info->filetime = -1; /* -1 is an illegal time and thus means unknown */ info->timecond = FALSE; - free(info->contenttype); - info->contenttype = NULL; - info->header_size = 0; info->request_size = 0; + info->proxyauthavail = 0; + info->httpauthavail = 0; info->numconnects = 0; + free(info->contenttype); + info->contenttype = NULL; + + free(info->wouldredirect); + info->wouldredirect = NULL; + info->conn_primary_ip[0] = '\0'; info->conn_local_ip[0] = '\0'; info->conn_primary_port = 0; info->conn_local_port = 0; +#ifdef USE_SSL + Curl_ssl_free_certinfo(data); +#endif + return CURLE_OK; } diff --git a/lib/urldata.h b/lib/urldata.h index 3ac050b53..d5efe2a97 100644 --- a/lib/urldata.h +++ b/lib/urldata.h @@ -1104,6 +1104,7 @@ struct connectdata { /* * Struct to keep statistical and informational data. + * All variables in this struct must be reset in Curl_initinfo(). */ struct PureInfo { int httpcode; /* Recent HTTP, FTP, RTSP or SMTP response code */ -- cgit v1.2.3