]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Tightened size checks in reserveSpace, reserveCapacity and rawSpace
authorFrancesco Chemolli <kinkie@squid-cache.org>
Wed, 31 Jul 2013 16:11:54 +0000 (18:11 +0200)
committerFrancesco Chemolli <kinkie@squid-cache.org>
Wed, 31 Jul 2013 16:11:54 +0000 (18:11 +0200)
src/SBuf.cc
src/SBuf.h

index 64f1a82d69663543d251c78228a55cd73998d0e9..933634652cf5da87da9a4f3fdf28b32e1b62175c 100644 (file)
@@ -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,
index 91ae9ae34d254cd9fdedaaec0b8ec0fef55ccffb..6e64aa988ac693d87243327a5fa3d8cbe3ea0534 100644 (file)
@@ -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
      *