]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
- fixed loop detection code; we must use strstr instead of strcmp when
authorrousskov <>
Thu, 21 May 1998 06:57:35 +0000 (06:57 +0000)
committerrousskov <>
Thu, 21 May 1998 06:57:35 +0000 (06:57 +0000)
  searching for ThisCache in a Via headers.

src/HttpHeaderTools.cc
src/client_side.cc

index 8268401d5809d0d4247ae1b42cb542a387b36f18..727f11962d74429524997d15e826351a87c91f38 100644 (file)
@@ -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)
index be8d1a03cebb6bd6059ac9225bf01e7572bc1fad..efb3151ce6cb72bfe1ef429da1059c9e4b1f010a 100644 (file)
@@ -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);