From: rousskov <> Date: Thu, 21 May 1998 06:57:35 +0000 (+0000) Subject: - fixed loop detection code; we must use strstr instead of strcmp when X-Git-Tag: SQUID_3_0_PRE1~3299 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=edf3ffdc29abbd9180c2bbe9a848e20cbcf4ca4f;p=thirdparty%2Fsquid.git - fixed loop detection code; we must use strstr instead of strcmp when searching for ThisCache in a Via headers. --- diff --git a/src/HttpHeaderTools.cc b/src/HttpHeaderTools.cc index 8268401d58..727f11962d 100644 --- a/src/HttpHeaderTools.cc +++ b/src/HttpHeaderTools.cc @@ -1,5 +1,5 @@ /* - * $Id: HttpHeaderTools.cc,v 1.11 1998/05/11 18:44:27 rousskov Exp $ + * $Id: HttpHeaderTools.cc,v 1.12 1998/05/21 00:57:35 rousskov Exp $ * * DEBUG: section 66 HTTP Header Tools * AUTHOR: Alex Rousskov @@ -139,6 +139,20 @@ strListIsMember(const String *list, const char *m, char del) return 0; } +/* returns true iff "s" is a substring of a member of the list */ +int +strListIsSubstr(const String *list, const char *s, char del) +{ + const char *pos = NULL; + const char *item; + assert(list && s); + while (strListGetItem(list, del, &item, NULL, &pos)) { + if (strstr(item, s)) + return 1; + } + return 0; +} + /* appends an item to the list */ void strListAdd(String *str, const char *item, char del) diff --git a/src/client_side.cc b/src/client_side.cc index be8d1a03ce..efb3151ce6 100644 --- a/src/client_side.cc +++ b/src/client_side.cc @@ -1,6 +1,6 @@ /* - * $Id: client_side.cc,v 1.309 1998/05/20 22:07:08 wessels Exp $ + * $Id: client_side.cc,v 1.310 1998/05/21 00:57:36 rousskov Exp $ * * DEBUG: section 33 Client-side Routines * AUTHOR: Duane Wessels @@ -761,7 +761,8 @@ clientInterpretRequestHeaders(clientHttpRequest * http) #endif if (httpHeaderHas(req_hdr, HDR_VIA)) { String s = httpHeaderGetList(req_hdr, HDR_VIA); - if (strListIsMember(&s, ThisCache, ',')) { + /* ThisCache cannot be a member of Via header, "1.0 ThisCache" can */ + if (strListIsSubstr(&s, ThisCache, ',')) { if (!http->flags.accel) { debug(33, 1) ("WARNING: Forwarding loop detected for '%s'\n", http->uri);