From: Amos Jeffries Date: Mon, 29 Sep 2014 05:13:17 +0000 (-0700) Subject: Cleanup: fix various uninitialized class members X-Git-Tag: SQUID_3_5_0_1~31 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=4579a6d0759644dc71b583c0ab480ffd4ef57d42;p=thirdparty%2Fsquid.git Cleanup: fix various uninitialized class members Also, simplify some destructors. xfree() is faster than safe_free() and both are ok in a destructor. Detected by Coverity Scan. Issue 971423, 1135444, 1135445, 1231353, 1231354, 1231355, 1231356, 1234503, 1241504, 740531, 740566 --- diff --git a/src/AccessLogEntry.h b/src/AccessLogEntry.h index 67c8f45350..5c69f29a8a 100644 --- a/src/AccessLogEntry.h +++ b/src/AccessLogEntry.h @@ -147,8 +147,10 @@ public: #if USE_OPENSSL ssluser(NULL), #endif - port(NULL) { + port(NULL) + { caddr.setNoAddr(); + memset(&start_time, 0, sizeof(start_time)); } Ip::Address caddr; diff --git a/src/Notes.h b/src/Notes.h index ba8e6f3955..0e8a92e621 100644 --- a/src/Notes.h +++ b/src/Notes.h @@ -81,7 +81,7 @@ public: typedef NotesList::const_iterator const_iterator; ///< iterates over the notes list Notes(const char *aDescr, const char **metasBlacklist, bool allowFormatted = false): descr(aDescr), blacklisted(metasBlacklist), formattedValues(allowFormatted) {} - Notes(): descr(NULL), blacklisted(NULL) {} + Notes(): descr(NULL), blacklisted(NULL), formattedValues(false) {} ~Notes() { notes.clear(); } /** * Parse a notes line and returns a pointer to the diff --git a/src/acl/Acl.h b/src/acl/Acl.h index 7170b90159..7c5be41b77 100644 --- a/src/acl/Acl.h +++ b/src/acl/Acl.h @@ -80,7 +80,9 @@ public: static ACL *FindByName(const char *name); ACL(); - explicit ACL(const ACLFlag flgs[]) : cfgline(NULL), next(NULL), flags(flgs) { memset(name, '\0', sizeof(name)); } + explicit ACL(const ACLFlag flgs[]) : cfgline(NULL), next(NULL), flags(flgs), registered(false) { + *name = 0; + } virtual ~ACL(); /// sets user-specified ACL name and squid.conf context diff --git a/src/adaptation/icap/Config.cc b/src/adaptation/icap/Config.cc index ab5b465b6c..3ce95261da 100644 --- a/src/adaptation/icap/Config.cc +++ b/src/adaptation/icap/Config.cc @@ -19,6 +19,7 @@ Adaptation::Icap::Config Adaptation::Icap::TheConfig; Adaptation::Icap::Config::Config() : + default_options_ttl(0), preview_enable(0), preview_size(0), allow206_enable(0), connect_timeout_raw(0), io_timeout_raw(0), reuse_connections(0), client_username_header(NULL), client_username_encode(0), repeat(NULL), diff --git a/src/client_side.cc b/src/client_side.cc index bb20f93ce5..f22f3b4fd3 100644 --- a/src/client_side.cc +++ b/src/client_side.cc @@ -3481,14 +3481,22 @@ clientLifetimeTimeout(const CommTimeoutCbParams &io) ConnStateData::ConnStateData(const MasterXaction::Pointer &xact) : AsyncJob("ConnStateData"), // kids overwrite + nrequests(0), #if USE_OPENSSL sslBumpMode(Ssl::bumpEnd), +#endif + needProxyProtocolHeader_(false), +#if USE_OPENSSL switchedToHttps_(false), sslServerBump(NULL), + signAlgorithm(Ssl::algSignTrusted), #endif stoppedSending_(NULL), stoppedReceiving_(NULL) { + flags.readMore = true; // kids may overwrite + flags.swanSang = false; + pinning.host = NULL; pinning.port = -1; pinning.pinned = false; @@ -3501,8 +3509,6 @@ ConnStateData::ConnStateData(const MasterXaction::Pointer &xact) : port = xact->squidPort; log_addr = xact->tcpClient->remote; log_addr.applyMask(Config.Addrs.client_netmask); - - flags.readMore = true; // kids may overwrite } void diff --git a/src/clients/Client.cc b/src/clients/Client.cc index ccbac5d499..d09833ca28 100644 --- a/src/clients/Client.cc +++ b/src/clients/Client.cc @@ -38,6 +38,10 @@ void purgeEntriesByUrl(HttpRequest * req, const char *url); Client::Client(FwdState *theFwdState): AsyncJob("Client"), + completed(false), + currentOffset(0), + responseBodyBuffer(NULL), + fwd(theFwdState), requestSender(NULL), #if USE_ADAPTATION adaptedHeadSource(NULL), @@ -48,9 +52,7 @@ Client::Client(FwdState *theFwdState): AsyncJob("Client"), theVirginReply(NULL), theFinalReply(NULL) { - fwd = theFwdState; entry = fwd->entry; - entry->lock("Client"); request = fwd->request; diff --git a/src/clients/FtpGateway.cc b/src/clients/FtpGateway.cc index 254db92db6..1ce0f7ac84 100644 --- a/src/clients/FtpGateway.cc +++ b/src/clients/FtpGateway.cc @@ -331,12 +331,28 @@ Ftp::Gateway::dataClosed(const CommCloseCbParams &io) Ftp::Gateway::Gateway(FwdState *fwdState): AsyncJob("FtpStateData"), - Ftp::Client(fwdState) -{ - const char *url = entry->url(); - debugs(9, 3, HERE << "'" << url << "'" ); - theSize = -1; - mdtm = -1; + Ftp::Client(fwdState), + password_url(0), + reply_hdr(NULL), + reply_hdr_state(0), + conn_att(0), + login_att(0), + mdtm(-1), + theSize(-1), + pathcomps(NULL), + filepath(NULL), + dirpath(NULL), + restart_offset(0), + proxy_host(NULL), + list_width(0), + old_filepath(NULL), + typecode('\0') +{ + debugs(9, 3, entry->url()); + + *user = 0; + *password = 0; + memset(&flags, 0, sizeof(flags)); if (Config.Ftp.passive && !flags.pasv_failed) flags.pasv_supported = 1; @@ -351,7 +367,7 @@ Ftp::Gateway::Gateway(FwdState *fwdState): Ftp::Gateway::~Gateway() { - debugs(9, 3, HERE << entry->url() ); + debugs(9, 3, entry->url()); if (Comm::IsConnOpen(ctrl.conn)) { debugs(9, DBG_IMPORTANT, "Internal bug: FTP Gateway left open " << @@ -367,16 +383,11 @@ Ftp::Gateway::~Gateway() wordlistDestroy(&pathcomps); cwd_message.clean(); - - safe_free(old_filepath); - + xfree(old_filepath); title_url.clean(); - base_href.clean(); - - safe_free(filepath); - - safe_free(dirpath); + xfree(filepath); + xfree(dirpath); } /** diff --git a/src/clients/FtpRelay.cc b/src/clients/FtpRelay.cc index 5c11a23d6e..190595f266 100644 --- a/src/clients/FtpRelay.cc +++ b/src/clients/FtpRelay.cc @@ -137,6 +137,7 @@ const Ftp::Relay::SM_FUNC Ftp::Relay::SM_FUNCS[] = { Ftp::Relay::Relay(FwdState *const fwdState): AsyncJob("Ftp::Relay"), Ftp::Client(fwdState), + thePreliminaryCb(NULL), forwardingCompleted(false) { savedReply.message = NULL; diff --git a/src/helper/Request.h b/src/helper/Request.h index 569bc8dc35..9c4fbc076a 100644 --- a/src/helper/Request.h +++ b/src/helper/Request.h @@ -22,7 +22,10 @@ public: callback(c), data(cbdataReference(d)), placeholder(b == NULL) - {} + { + memset(&dispatch_time, 0, sizeof(dispatch_time)); + } + ~Request() { cbdataReferenceDone(data); xfree(buf); diff --git a/src/htcp.cc b/src/htcp.cc index e8f2be9ffc..00a10b3c1e 100644 --- a/src/htcp.cc +++ b/src/htcp.cc @@ -1067,7 +1067,9 @@ htcpHandleTst(htcpDataHeader * hdr, char *buf, int sz, Ip::Address &from) HtcpReplyData::HtcpReplyData() : hit(0), hdr(hoHtcpReply), msg_id(0), version(0.0) -{} +{ + memset(&cto, 0, sizeof(cto)); +} static void diff --git a/src/servers/FtpServer.cc b/src/servers/FtpServer.cc index c459a5cfef..9d622ba32b 100644 --- a/src/servers/FtpServer.cc +++ b/src/servers/FtpServer.cc @@ -62,6 +62,7 @@ Ftp::Server::Server(const MasterXaction::Pointer &xact): reader() { flags.readMore = false; // we need to announce ourselves first + *uploadBuf = 0; } Ftp::Server::~Server()