From: Francesco Chemolli Date: Wed, 27 Apr 2022 15:41:26 +0000 (+0000) Subject: Initialize all HttpStateData data members (#1029) X-Git-Tag: SQUID_6_0_1~202 X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=c31f43b9fbd881431917efcd52a9ebd8d879af9d;p=thirdparty%2Fsquid.git Initialize all HttpStateData data members (#1029) If fwd->serverConnection is null, _peer is read before being initialized. We now make sure all HttpStateData data members are initialized (using in-class member initialization). Detected by Coverity. CID 1494356: Uninitialized pointer read (UNINIT). Also removed HttpStateData::read_sz as unused. --- diff --git a/src/http.cc b/src/http.cc index 027514032d..b8a5072fea 100644 --- a/src/http.cc +++ b/src/http.cc @@ -76,16 +76,9 @@ static void copyOneHeaderFromClientsideRequestToUpstreamRequest(const HttpHeader HttpStateData::HttpStateData(FwdState *theFwdState) : AsyncJob("HttpStateData"), - Client(theFwdState), - lastChunk(0), - httpChunkDecoder(NULL), - payloadSeen(0), - payloadTruncated(0), - sawDateGoBack(false) + Client(theFwdState) { debugs(11,5, "HttpStateData " << this << " created"); - ignoreCacheControl = false; - surrogateNoStore = false; serverConnection = fwd->serverConnection(); if (fwd->serverConnection() != NULL) diff --git a/src/http.h b/src/http.h index e70cd7e037..c4161211f8 100644 --- a/src/http.h +++ b/src/http.h @@ -61,14 +61,13 @@ public: // Checks whether the response is cacheable/shareable. ReuseDecision::Answers reusableReply(ReuseDecision &decision); - CachePeer *_peer; /* CachePeer request made to */ - int eof; /* reached end-of-object? */ - int lastChunk; /* reached last chunk of a chunk-encoded reply */ + CachePeer *_peer = nullptr; /* CachePeer request made to */ + int eof = 0; /* reached end-of-object? */ + int lastChunk = 0; /* reached last chunk of a chunk-encoded reply */ Http::StateFlags flags; - size_t read_sz; SBuf inBuf; ///< I/O buffer for receiving server responses - bool ignoreCacheControl; - bool surrogateNoStore; + bool ignoreCacheControl = false; + bool surrogateNoStore = false; /// Upgrade header value sent to the origin server or cache peer. String *upgradeHeaderOut = nullptr; @@ -147,16 +146,16 @@ private: /// Parser being used at present to parse the HTTP/ICY server response. Http1::ResponseParserPointer hp; - Http1::TeChunkedParser *httpChunkDecoder; + Http1::TeChunkedParser *httpChunkDecoder = nullptr; /// amount of message payload/body received so far. - int64_t payloadSeen; + int64_t payloadSeen = 0; /// positive when we read more than we wanted - int64_t payloadTruncated; + int64_t payloadTruncated = 0; /// Whether we received a Date header older than that of a matching /// cached response. - bool sawDateGoBack; + bool sawDateGoBack = false; }; std::ostream &operator <<(std::ostream &os, const HttpStateData::ReuseDecision &d);