From: Francesco Chemolli Date: Sun, 1 Mar 2009 22:19:44 +0000 (+0100) Subject: Added guards against undefnined Strings in the pos()family. X-Git-Tag: SQUID_3_2_0_1~1144^2~1 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=4f4611bffe2916333477046a5976bb3affd22fe3;p=thirdparty%2Fsquid.git Added guards against undefnined Strings in the pos()family. --- diff --git a/src/HttpHeaderTools.cc b/src/HttpHeaderTools.cc index 33ac3d5712..24b285076d 100644 --- a/src/HttpHeaderTools.cc +++ b/src/HttpHeaderTools.cc @@ -189,7 +189,6 @@ int strListIsSubstr(const String * list, const char *s, char del) { assert(list && del); - return list->pos(s) != 0; /** \note * Note: the original code with a loop is broken because it uses strstr() @@ -359,7 +358,7 @@ httpHeaderParseQuotedString (const char *start, String *val) /** * Checks the anonymizer (header_access) configuration. - * + * * \retval 0 Header is explicitly blocked for removal * \retval 1 Header is explicitly allowed * \retval 1 Header has been replaced, the current version can be used. diff --git a/src/String.cc b/src/String.cc index 90758326fe..a68af96883 100644 --- a/src/String.cc +++ b/src/String.cc @@ -437,18 +437,24 @@ checkNullString(const char *p) const char * String::pos(char const *aString) const { + if (undefined()) + return NULL; return strstr(termedBuf(), aString); } const char * String::pos(char const ch) const { + if (undefined()) + return NULL; return strchr(termedBuf(), ch); } const char * String::rpos(char const ch) const { + if (undefined()) + return NULL; return strrchr(termedBuf(), (ch)); }