From: amosjeffries <> Date: Wed, 27 Feb 2008 17:47:59 +0000 (+0000) Subject: Several String fixes. X-Git-Tag: SQUID_3_0_STABLE2~13 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d3925e87702bfdcabc2a70a66c095c967018acda;p=thirdparty%2Fsquid.git Several String fixes. - 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 --- diff --git a/src/SquidString.h b/src/SquidString.h index c2f371d2b2..a0394c8a79 100644 --- a/src/SquidString.h +++ b/src/SquidString.h @@ -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; diff --git a/src/String.cci b/src/String.cci index ccc48f4ac0..5e90b8a821 100644 --- a/src/String.cci +++ b/src/String.cci @@ -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'; }