From: Francesco Chemolli Date: Wed, 31 Jul 2013 16:11:54 +0000 (+0200) Subject: Tightened size checks in reserveSpace, reserveCapacity and rawSpace X-Git-Tag: SQUID_3_5_0_1~612^2~5 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=e842ecce1a66dea8ddbf12c769ad74c25c1c1c74;p=thirdparty%2Fsquid.git Tightened size checks in reserveSpace, reserveCapacity and rawSpace --- diff --git a/src/SBuf.cc b/src/SBuf.cc index 64f1a82d69..933634652c 100644 --- a/src/SBuf.cc +++ b/src/SBuf.cc @@ -183,14 +183,16 @@ SBuf::assign(const char *S, size_type n) void SBuf::reserveCapacity(size_type minCapacity) { - Must(0 <= minCapacity); //upper bound checked in cow -> reAlloc + Must(0 <= minCapacity); + Must(minCapacity <= maxSize); cow(minCapacity); } char * SBuf::rawSpace(size_type minSpace) { - Must(0 <= minSpace); //upper bound checked in cow -> reAlloc + Must(0 <= minSpace); + Must(minSpace <= maxSize); debugs(24, 7, "reserving " << minSpace << " for " << id); ++stats.rawAccess; // we're not concerned about RefCounts here, diff --git a/src/SBuf.h b/src/SBuf.h index 91ae9ae34d..6e64aa988a 100644 --- a/src/SBuf.h +++ b/src/SBuf.h @@ -416,7 +416,11 @@ public: * used portion and single ownership of the backing store. * \throw SBufTooBigException if the user tries to allocate too big a SBuf */ - void reserveSpace(size_type minSpace) {reserveCapacity(length()+minSpace);} + void reserveSpace(size_type minSpace) { + Must(0 <= minSpace); + Must(minSpace <= maxSize); + reserveCapacity(length()+minSpace); + } /** Request to guarantee the SBuf's store capacity *