]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Bugzilla #458: segmentation fault if external_acl helper exits
authorhno <>
Fri, 15 Nov 2002 20:27:58 +0000 (20:27 +0000)
committerhno <>
Fri, 15 Nov 2002 20:27:58 +0000 (20:27 +0000)
This patch allows Squid to deal more gracefully if a external_acl helper
exits. Instead of crashing with a segfault Squid now repeats the query
to the next available helper.

src/external_acl.cc

index 259379d1c9556cc17f25c69fd0730bff669748f6..0e049a3be4ea6df7c514a37cf4380a05a9922925 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: external_acl.cc,v 1.17 2002/11/10 04:41:06 hno Exp $
+ * $Id: external_acl.cc,v 1.18 2002/11/15 13:27:58 hno Exp $
  *
  * DEBUG: section 82    External ACL
  * AUTHOR: Henrik Nordstrom, MARA Systems AB
@@ -691,25 +691,32 @@ externalAclHandleReply(void *data, char *reply)
 
     debug(82, 2) ("externalAclHandleReply: reply=\"%s\"\n", reply);
 
-    status = strwordtok(reply, &t);
-    if (status && strcmp(status, "OK") == 0)
-       result = 1;
-
-    while ((token = strwordtok(NULL, &t))) {
-       value = strchr(token, '=');
-       if (value) {
-           *value++ = '\0';    /* terminate the token, and move up to the value */
-           if (strcmp(token, "user") == 0)
-               user = value;
-           else if (strcmp(token, "error") == 0)
-               error = value;
+    if (reply) {
+       status = strwordtok(reply, &t);
+       if (status && strcmp(status, "OK") == 0)
+           result = 1;
+
+       while ((token = strwordtok(NULL, &t))) {
+           value = strchr(token, '=');
+           if (value) {
+               *value++ = '\0';        /* terminate the token, and move up to the value */
+               if (strcmp(token, "user") == 0)
+                   user = value;
+               else if (strcmp(token, "error") == 0)
+                   error = value;
+           }
        }
     }
-
     dlinkDelete(&state->list, &state->def->queue);
-    if (cbdataReferenceValid(state->def))
-       entry = external_acl_cache_add(state->def, state->key, result, user, error);
-    else
+    if (cbdataReferenceValid(state->def)) {
+       if (reply)
+           entry = external_acl_cache_add(state->def, state->key, result, user, error);
+       else {
+           entry = hash_lookup(state->def->cache, state->key);
+           if (entry)
+               external_acl_cache_delete(state->def, entry);
+       }
+    } else
        entry = NULL;
 
     do {