]> git.ipfire.org Git - thirdparty/squid.git/blobdiff - src/acl/Arp.cc
Source Format Enforcement (#1234)
[thirdparty/squid.git] / src / acl / Arp.cc
index d6048f3dbe64aac5e8c42104d91826afefa980c2..5c522de97b502e0bf6dfe6405b6b9f8ac3486f73 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1996-2015 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.
 #include "acl/Arp.h"
 #include "acl/FilledChecklist.h"
 #include "cache_cf.h"
-#include "Debug.h"
+#include "debug/Stream.h"
 #include "eui/Eui48.h"
 #include "globals.h"
 #include "ip/Address.h"
 
 #include <algorithm>
 
-ACL *
-ACLARP::clone() const
-{
-    return new ACLARP(*this);
-}
-
 ACLARP::ACLARP (char const *theClass) : class_ (theClass)
 {}
 
-ACLARP::ACLARP (ACLARP const & old) : class_ (old.class_), aclArpData(old.aclArpData)
-{
-}
-
-ACLARP::~ACLARP()
-{
-}
-
 char const *
 ACLARP::typeString() const
 {
@@ -63,7 +49,7 @@ ACLARP::empty () const
  * Working on setting up a proper firewall for a network containing some
  * Win'95 computers at our Univ, I've discovered that some smart students
  * avoid the restrictions easily just changing their IP addresses in Win'95
- * Contol Panel... It has been getting boring, so I took Squid-1.1.18
+ * Control Panel... It has been getting boring, so I took Squid-1.1.18
  * sources and added a new acl type for hard-wired access control:
  *
  * acl <name> arp <Ethernet address> ...
@@ -77,7 +63,7 @@ ACLARP::empty () const
  *       Solaris code by R. Gancarz <radekg@solaris.elektrownia-lagisza.com.pl>
  */
 
-Eui::Eui48 *
+static Eui::Eui48 *
 aclParseArpData(const char *t)
 {
     char buf[256];
@@ -85,16 +71,16 @@ aclParseArpData(const char *t)
     debugs(28, 5, "aclParseArpData: " << t);
 
     if (sscanf(t, "%[0-9a-fA-F:]", buf) != 1) {
-        debugs(28, DBG_CRITICAL, "aclParseArpData: Bad ethernet address: '" << t << "'");
-        safe_free(q);
-        return NULL;
+        debugs(28, DBG_CRITICAL, "ERROR: aclParseArpData: Bad ethernet address: '" << t << "'");
+        delete q;
+        return nullptr;
     }
 
     if (!q->decode(buf)) {
         debugs(28, DBG_CRITICAL, "" << cfg_filename << " line " << config_lineno << ": " << config_input_line);
-        debugs(28, DBG_CRITICAL, "aclParseArpData: Ignoring invalid ARP acl entry: can't parse '" << buf << "'");
-        safe_free(q);
-        return NULL;
+        debugs(28, DBG_CRITICAL, "ERROR: aclParseArpData: Ignoring invalid ARP acl entry: cannot parse '" << buf << "'");
+        delete q;
+        return nullptr;
     }
 
     return q;
@@ -106,17 +92,12 @@ aclParseArpData(const char *t)
 void
 ACLARP::parse()
 {
-    char *t = NULL;
-    Eui::Eui48 *q = NULL;
-
-    while ((t = strtokFile())) {
-        if ((q = aclParseArpData(t)) == NULL)
-            continue;
-
-        aclArpData.insert(*q);
-        safe_free(q);
+    while (const char *t = ConfigParser::strtokFile()) {
+        if (Eui::Eui48 *q = aclParseArpData(t)) {
+            aclArpData.insert(*q);
+            delete q;
+        }
     }
-
 }
 
 int
@@ -139,7 +120,7 @@ SBufList
 ACLARP::dump() const
 {
     SBufList sl;
-    for (auto i = aclArpData.cbegin(); i != aclArpData.cend(); ++i) {
+    for (auto i = aclArpData.begin(); i != aclArpData.end(); ++i) {
         char buf[48];
         i->encode(buf,48);
         sl.push_back(SBuf(buf));