From: Alex Rousskov Date: Fri, 6 Dec 2013 12:18:19 +0000 (-0700) Subject: Destroy ACLs in the reverse order of creation to avoid destruction segfaults X-Git-Tag: SQUID_3_4_1~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2a92e4f83456d968472d9c1cdb6419f17eeefca6;p=thirdparty%2Fsquid.git Destroy ACLs in the reverse order of creation to avoid destruction segfaults during reconfiguration. Group ACLs created later may use other ACLs created earlier. A group ACL must be deleted first so that its AclDeleter can safely access registration status (and avoid double deletion) of the ACLs it uses. Since ACLs are remembered (in Config.aclList) using a singly-linked list, it is difficult to change their deletion order. Instead, we change their listing order from FIFO to LIFO. --- diff --git a/src/acl/Acl.cc b/src/acl/Acl.cc index bc090277a6..7b7a42dcd2 100644 --- a/src/acl/Acl.cc +++ b/src/acl/Acl.cc @@ -298,13 +298,11 @@ ACL::ParseAclLine(ConfigParser &parser, ACL ** head) A->cfgline); } - /* append */ + // prepend so that ACLs declared later (and possibly using earlier ACLs) + // are destroyed earlier (before the ACLs they use are destroyed) assert(head && *head == Config.aclList); A->registered = true; - - while (*head) - head = &(*head)->next; - + A->next = *head; *head = A; }