]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Several String fixes.
authoramosjeffries <>
Wed, 27 Feb 2008 17:47:59 +0000 (17:47 +0000)
committeramosjeffries <>
Wed, 27 Feb 2008 17:47:59 +0000 (17:47 +0000)
- Add two missing includes when configured --disable-inline
- SegFault when newly allocated string set to 0-length.
  buf_ may be NULL and buffer overruns on truncate attempt

src/SquidString.h
src/String.cci

index c2f371d2b2eaeade77b0772686782007ccb77e50..a0394c8a79183411e2750cc138990d011ad63fd7 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: SquidString.h,v 1.12 2007/11/04 23:59:51 amosjeffries Exp $
+ * $Id: SquidString.h,v 1.12.2.1 2008/02/27 10:47:59 amosjeffries Exp $
  *
  * DEBUG: section 67    String
  * AUTHOR: Duane Wessels
@@ -36,6 +36,8 @@
 #ifndef SQUID_STRING_H
 #define SQUID_STRING_H
 
+#include "config.h"
+
 /* forward decls */
 
 class CacheManager;
index ccc48f4ac0b076ed7634b5bc2b9499b712393bd1..5e90b8a821f2fab25835136244034a8194d61f6d 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: String.cci,v 1.10 2007/11/04 23:59:52 amosjeffries Exp $
+ * $Id: String.cci,v 1.10.2.1 2008/02/27 10:47:59 amosjeffries Exp $
  *
  * DEBUG: section 67    String
  * AUTHOR: Duane Wessels
@@ -33,6 +33,8 @@
  *
  */
 
+#include "assert.h"
+
 String::String() : size_(0), len_(0), buf_ (NULL)
 {
 #if DEBUGSTRINGS
@@ -150,6 +152,8 @@ String::cut(size_t newLength)
     if(newLength < 0 || newLength > len_) return;
 
     len_ = newLength;
+
+    if(len_ == 0 && buf_ == NULL) return; // buf_ may be NULL on zero-length strings.
     buf_[newLength] = '\0';
 }