]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Cleanup: fix various uninitialized class members
authorAmos Jeffries <squid3@treenet.co.nz>
Mon, 29 Sep 2014 05:13:17 +0000 (22:13 -0700)
committerAmos Jeffries <squid3@treenet.co.nz>
Mon, 29 Sep 2014 05:13:17 +0000 (22:13 -0700)
Also, simplify some destructors. xfree() is faster than
safe_free() and both are ok in a destructor.

  Detected by Coverity Scan. Issue 971423, 11354441135445,
    123135312313541231355123135612345031241504,
    740531, 740566

src/AccessLogEntry.h
src/Notes.h
src/acl/Acl.h
src/adaptation/icap/Config.cc
src/client_side.cc
src/clients/Client.cc
src/clients/FtpGateway.cc
src/clients/FtpRelay.cc
src/helper/Request.h
src/htcp.cc
src/servers/FtpServer.cc

index 67c8f453505e7551445e9dac75db20d98f26345c..5c69f29a8a27b633be9cece928fbf2d1ade64b4c 100644 (file)
@@ -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;
index ba8e6f39554da7f7545eb716460644a22bb0e8d6..0e8a92e621945c35463f78c2ebceeec47f8fac35 100644 (file)
@@ -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
index 7170b9015916cf287214fbf2c196da4a0ee4cbab..7c5be41b7720d16c30dc76cdb3ce0f968627215b 100644 (file)
@@ -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
index ab5b465b6cb10a17bdb9bd080f48f826d7c7fa64..3ce95261daa420a86f0dde1f31a3bf5704c727b3 100644 (file)
@@ -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),
index bb20f93ce5926e3d1589d95e23403a46f62a61b2..f22f3b4fd3c6d9946d10c13cd0a5543d2271bc55 100644 (file)
@@ -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
index ccbac5d499fe9962de808c9248836ecccc1afce2..d09833ca28cd0826e788c98f84e6269b36e71186 100644 (file)
 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;
index 254db92db636aac23ae65ac1b2bf118d9b3ffaa7..1ce0f7ac848427fc3d64502a5badd7533e98074a 100644 (file)
@@ -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);
 }
 
 /**
index 5c11a23d6e141be5d253c489dbbefff25d116411..190595f2668069ace7cabcb4077977f20a438dac 100644 (file)
@@ -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;
index 569bc8dc3563fe7afde8e9d246b6c3f40a8d88ad..9c4fbc076a1376db260c56e78bfb9387ea4f9329 100644 (file)
@@ -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);
index e8f2be9ffc19a56fdce48a266ec72345850e02ab..00a10b3c1e258525b1ac35c6d3f3aa6d27ffa5cc 100644 (file)
@@ -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
 
index c459a5cfef7c80fd396b6ed6c533826dc0c347cb..9d622ba32b17b13d5f56ee66414f8c53c9504c5f 100644 (file)
@@ -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()