Commit 45646367 authored by Jay Satiro's avatar Jay Satiro
Browse files

easy: Initialize info variables on easy init and duphandle

- Call Curl_initinfo on init and duphandle.

Prior to this change the statistical and informational variables were
simply zeroed by calloc on easy init and duphandle. While zero is the
correct default value for almost all info variables, there is one where
it isn't (filetime initializes to -1).

Bug: https://github.com/curl/curl/issues/1103
Reported-by: Neal Poole
parent ebeffe81
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -927,6 +927,8 @@ struct Curl_easy *curl_easy_duphandle(struct Curl_easy *data)

  Curl_convert_setup(outcurl);

  Curl_initinfo(outcurl);

  outcurl->magic = CURLEASY_MAGIC_NUMBER;

  /* we reach this point and thus we are OK */
+5 −2
Original line number Diff line number Diff line
@@ -36,8 +36,11 @@
#include "memdebug.h"

/*
 * 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.
 * Initialize statistical and informational data.
 *
 * This function is called in curl_easy_reset, curl_easy_duphandle and at the
 * beginning of a perform session. It must reset the session-info variables,
 * in particular all variables in struct PureInfo.
 */
CURLcode Curl_initinfo(struct Curl_easy *data)
{
+3 −0
Original line number Diff line number Diff line
@@ -92,6 +92,7 @@ bool curl_win32_idn_to_ascii(const char *in, char **out);
#include "warnless.h"
#include "non-ascii.h"
#include "inet_pton.h"
#include "getinfo.h"

/* And now for the protocols */
#include "ftp.h"
@@ -646,6 +647,8 @@ CURLcode Curl_open(struct Curl_easy **curl)

    Curl_convert_init(data);

    Curl_initinfo(data);

    /* most recent connection is not yet defined */
    data->state.lastconnect = NULL;

+1 −1
Original line number Diff line number Diff line
@@ -1105,7 +1105,7 @@ struct connectdata {

/*
 * Struct to keep statistical and informational data.
 * All variables in this struct must be reset in Curl_initinfo().
 * All variables in this struct must be initialized/reset in Curl_initinfo().
 */
struct PureInfo {
  int httpcode;  /* Recent HTTP, FTP, RTSP or SMTP response code */
+1 −1
Original line number Diff line number Diff line
@@ -157,7 +157,7 @@ test1516 test1517 \
test1520 \
\
test1525 test1526 test1527 test1528 test1529 test1530 test1531 test1532 \
test1533 \
test1533 test1534 \
\
test1600 test1601 test1602 test1603 test1604 test1605 \
\
Loading