]> git.ipfire.org Git - thirdparty/squid.git/blobdiff - src/acl/BoolOps.cc
Source Format Enforcement (#1234)
[thirdparty/squid.git] / src / acl / BoolOps.cc
index 94f8cffb719a6959d8691cb2d3e9c6ca4b0f291e..659d9b4fcd24f84182e581cda59de1258590e49b 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1996-2016 The Squid Software Foundation and contributors
+ * Copyright (C) 1996-2023 The Squid Software Foundation and contributors
  *
  * Squid software is distributed under GPLv2+ license and includes
  * contributions from numerous individuals and organizations.
@@ -9,15 +9,18 @@
 #include "squid.h"
 #include "acl/BoolOps.h"
 #include "acl/Checklist.h"
-#include "Debug.h"
+#include "debug/Stream.h"
+#include "sbuf/SBuf.h"
 
 /* Acl::NotNode */
 
 Acl::NotNode::NotNode(ACL *acl)
 {
     assert(acl);
+    Must(strlen(acl->name) <= sizeof(name)-2);
     name[0] = '!';
-    strncat(&name[1], acl->name, sizeof(name)-1-1);
+    name[1] = '\0';
+    xstrncpy(&name[1], acl->name, sizeof(name)-1); // -1 for '!'
     add(acl);
 }
 
@@ -49,16 +52,6 @@ Acl::NotNode::typeString() const
     return "!";
 }
 
-ACL *
-Acl::NotNode::clone() const
-{
-    // Not implemented: we are not a named ACL type in squid.conf so nobody
-    // should try to create a NotNode instance by ACL type name (which is
-    // what clone() API is for -- it does not really clone anything).
-    assert(false);
-    return NULL;
-}
-
 SBufList
 Acl::NotNode::dump() const
 {
@@ -75,12 +68,6 @@ Acl::AndNode::typeString() const
     return "and";
 }
 
-ACL *
-Acl::AndNode::clone() const
-{
-    return new AndNode;
-}
-
 int
 Acl::AndNode::doMatch(ACLChecklist *checklist, Nodes::const_iterator start) const
 {
@@ -109,12 +96,6 @@ Acl::OrNode::typeString() const
     return "any-of";
 }
 
-ACL *
-Acl::OrNode::clone() const
-{
-    return new OrNode;
-}
-
 bool
 Acl::OrNode::bannedAction(ACLChecklist *, Nodes::const_iterator) const
 {