From: Thomas Hozza Date: Wed, 2 Jan 2013 03:44:55 +0000 (-0700) Subject: Import fixes for some defects found by Coverity Scan from Red Hat's patchset X-Git-Tag: SQUID_3_3_0_3~14 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c2fbe778bd068b482c575b201ccc927374c362f3;p=thirdparty%2Fsquid.git Import fixes for some defects found by Coverity Scan from Red Hat's patchset --- diff --git a/src/HttpHdrRange.cc b/src/HttpHdrRange.cc index f556d805a5..479e4f8e25 100644 --- a/src/HttpHdrRange.cc +++ b/src/HttpHdrRange.cc @@ -96,7 +96,7 @@ HttpHdrRangeSpec::parseInit(const char *field, int flen) return false; } else /* must have a '-' somewhere in _this_ field */ - if (!((p = strchr(field, '-')) || (p - field >= flen))) { + if (!((p = strchr(field, '-')) && (p - field < flen))) { debugs(64, 2, "invalid (missing '-') range-spec near: '" << field << "'"); return false; } else { diff --git a/src/MemObject.cc b/src/MemObject.cc index ecee3fdc76..59f8511822 100644 --- a/src/MemObject.cc +++ b/src/MemObject.cc @@ -182,7 +182,7 @@ MemObject::dump() const debugs(20, DBG_IMPORTANT, "MemObject->nclients: " << nclients); debugs(20, DBG_IMPORTANT, "MemObject->reply: " << _reply); debugs(20, DBG_IMPORTANT, "MemObject->request: " << request); - debugs(20, DBG_IMPORTANT, "MemObject->log_url: " << log_url << " " << checkNullString(log_url)); + debugs(20, DBG_IMPORTANT, "MemObject->log_url: " << checkNullString(log_url)); } HttpReply const * diff --git a/src/client_side.cc b/src/client_side.cc index 5af18295f8..4d57a35456 100644 --- a/src/client_side.cc +++ b/src/client_side.cc @@ -702,7 +702,8 @@ ClientHttpRequest::logRequest() if (request) al->adapted_request = HTTPMSGLOCK(request); accessLogLog(al, checklist); - updateCounters(); + if (request) + updateCounters(); if (getConn() != NULL && getConn()->clientConnection != NULL) clientdbUpdate(getConn()->clientConnection->remote, logType, AnyP::PROTO_HTTP, out.size); diff --git a/src/client_side_reply.cc b/src/client_side_reply.cc index 1bb7669527..b1c8d1b035 100644 --- a/src/client_side_reply.cc +++ b/src/client_side_reply.cc @@ -2067,10 +2067,14 @@ clientReplyContext::sendMoreData (StoreIOBuffer result) ConnStateData * conn = http->getConn(); - if (conn == NULL || !conn->isOpen()) { - // too late, our conn is closing - // TODO: should we also quit? - debugs(33,3, HERE << "not sending more data to a closing " << conn->clientConnection); + // too late, our conn is closing + // TODO: should we also quit? + if (conn == NULL) { + debugs(33,3, "not sending more data to a closed connection" ); + return; + } + if (!conn->isOpen()) { + debugs(33,3, "not sending more data to closing connection " << conn->clientConnection); return; } diff --git a/src/client_side_request.cc b/src/client_side_request.cc index 39e28bd19b..c8e15981a4 100644 --- a/src/client_side_request.cc +++ b/src/client_side_request.cc @@ -1757,6 +1757,7 @@ ClientHttpRequest::handleAdaptedHeader(HttpMsg *msg) clientStreamNode *node = (clientStreamNode *)client_stream.tail->prev->data; clientReplyContext *repContext = dynamic_cast(node->data.getRaw()); + assert(repContext); repContext->createStoreEntry(request->method, request->flags); EBIT_CLR(storeEntry()->flags, ENTRY_FWD_HDR_WAIT); diff --git a/src/esi/Esi.cc b/src/esi/Esi.cc index 082b6e123d..60c2344750 100644 --- a/src/esi/Esi.cc +++ b/src/esi/Esi.cc @@ -2077,12 +2077,13 @@ esiChoose::addElement(ESIElement::Pointer element) debugs (86,3, "esiChooseAdd: Added a new element, elements = " << elements.size()); - if (chosenelement == -1) - if ((dynamic_cast(element.getRaw()))-> - testsTrue()) { + if (chosenelement == -1) { + const esiWhen * topElement=dynamic_cast(element.getRaw()); + if (topElement && topElement->testsTrue()) { chosenelement = elements.size() - 1; debugs (86,3, "esiChooseAdd: Chose element " << elements.size()); } + } } return true; diff --git a/src/fs/ufs/UFSSwapDir.cc b/src/fs/ufs/UFSSwapDir.cc index 2c436de1d9..9497fb0783 100644 --- a/src/fs/ufs/UFSSwapDir.cc +++ b/src/fs/ufs/UFSSwapDir.cc @@ -236,7 +236,7 @@ Fs::Ufs::UFSSwapDir::changeIO(DiskIOModule *module) /* TODO: factor out these 4 lines */ ConfigOption *ioOptions = IO->io->getOptionTree(); - if (ioOptions) + if (currentIOOptions && ioOptions) currentIOOptions->options.push_back(ioOptions); }