From: robertc <> Date: Sat, 2 Sep 2006 04:57:44 +0000 (+0000) Subject: Fix bug #1568 - the assertion on the String having a buffer does not fit with X-Git-Tag: SQUID_3_0_PRE5~162 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=948078e3df4c6fad6cf601334d11d405b3a805c3;p=thirdparty%2Fsquid.git Fix bug #1568 - the assertion on the String having a buffer does not fit with the contract of String. Note some FIXME's in String.cci. --- diff --git a/src/HttpHeader.cc b/src/HttpHeader.cc index 39fba0ab2f..948dd57480 100644 --- a/src/HttpHeader.cc +++ b/src/HttpHeader.cc @@ -1,6 +1,6 @@ /* - * $Id: HttpHeader.cc,v 1.122 2006/06/07 22:39:33 hno Exp $ + * $Id: HttpHeader.cc,v 1.123 2006/09/01 22:57:44 robertc Exp $ * * DEBUG: section 55 HTTP Header * AUTHOR: Alex Rousskov @@ -831,16 +831,15 @@ HttpHeader::getList(http_hdr_type id) const } /* - * note: we might get an empty (len==0) string if there was an "empty" - * header; we must not get a NULL string though. + * note: we might get an empty (size==0) string if there was an "empty" + * header. This results in an empty length String, which may have a NULL + * buffer. */ - assert(s.buf()); - - /* temporary warning: remove it! @?@ @?@ @?@ */ + /* temporary warning: remove it? (Is it useful for diagnostics ?) */ if (!s.size()) - debug(55, 3) ("empty list header: %s (%d)\n", Headers[id].name.buf(), id); - - debug(55, 6) ("%p: joined for id %d: %s\n", this, id, s.buf()); + debugs(55, 3, "empty list header: " << Headers[id].name << "(" << id << ")"); + else + debugs(55, 6, this << ": joined for id " << id << ": " << s); return s; } diff --git a/src/String.cci b/src/String.cci index eda0341537..4a430658ad 100644 --- a/src/String.cci +++ b/src/String.cci @@ -1,6 +1,6 @@ /* - * $Id: String.cci,v 1.5 2006/05/03 14:04:44 robertc Exp $ + * $Id: String.cci,v 1.6 2006/09/01 22:57:44 robertc Exp $ * * DEBUG: section 67 String * AUTHOR: Duane Wessels @@ -136,14 +136,14 @@ String::caseCmp (char const *aString, size_t count) const return strncasecmp(buf(), aString, count); } +/* FIXME: this is can perform buffer overflows and underflows! */ void - -String::set - (char const *loc, char const ch) +String::set (char const *loc, char const ch) { buf_[loc-buf_] = ch; } +/* FIXME: this is can perform buffer overflows and underflows! */ void String::cut (size_t newLength) { @@ -151,6 +151,7 @@ String::cut (size_t newLength) buf_[newLength] = '\0'; } +/* FIXME: this is can perform buffer overflows and underflows! */ void String::cutPointer (char const *loc) {