]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Protect String::limitInit() against empty strings.
authoramosjeffries <>
Thu, 24 Jan 2008 03:51:16 +0000 (03:51 +0000)
committeramosjeffries <>
Thu, 24 Jan 2008 03:51:16 +0000 (03:51 +0000)
Is being caleld at least once in squid3 with a NULL ptr and 0 length.
This patch prevents memory allocation on 0 length and a will continue
to assert if a NULL pointer is given with a length.
(We may want to re-think that later)

src/String.cc

index 7dc48a694cb1dd97b2309b535976a040b4a633d4..63e8389da9c9a37cedf989e7f63ff9368f35800d 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: String.cc,v 1.28 2008/01/23 19:24:14 rousskov Exp $
+ * $Id: String.cc,v 1.29 2008/01/23 20:51:16 amosjeffries Exp $
  *
  * DEBUG: section 67    String
  * AUTHOR: Duane Wessels
@@ -109,7 +109,12 @@ void
 String::limitInit(const char *str, int len)
 {
     PROF_start(StringLimitInit);
-    assert(this && str);
+    if(len < 1) {
+        clean();
+        return;
+    }
+
+    assert(this && str && len > 0);
     initBuf(len + 1);
     len_ = len;
     xmemcpy(buf_, str, len);