]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
libeui: Warn and fail nicely on socket errors looking up ARP record
authorAmos Jeffries <squid3@treenet.co.nz>
Fri, 30 Nov 2012 13:34:06 +0000 (06:34 -0700)
committerAmos Jeffries <squid3@treenet.co.nz>
Fri, 30 Nov 2012 13:34:06 +0000 (06:34 -0700)
If something nasty happened (out of FD or similar) socket() may fail.
Report these events and continue with unknown EUI value.

 Detected by Coverity Scan. Issue 740393

src/eui/Eui48.cc

index 91d86d948795b4a156747a556cc4cef2d7101f04..4464a996a6113ea31126f4fea11bcb2ecd944b6e 100644 (file)
@@ -174,6 +174,11 @@ Eui::Eui48::lookup(const Ip::Address &c)
 
     /* IPv6 builds do not provide the first http_port as an IPv4 socket for ARP */
     int tmpSocket = socket(AF_INET,SOCK_STREAM,0);
+    if (tmpSocket < 0) {
+        debugs(28, DBG_IMPORTANT, "Attempt to open socket for EUI retrieval failed: " << xstrerror());
+        clear();
+        return false;
+    }
 
     /*
      * The linux kernel 2.2 maintains per interface ARP caches and
@@ -313,6 +318,11 @@ Eui::Eui48::lookup(const Ip::Address &c)
 
     /* IPv6 builds do not provide the first http_port as an IPv4 socket for ARP */
     int tmpSocket = socket(AF_INET,SOCK_STREAM,0);
+    if (tmpSocket < 0) {
+        debugs(28, DBG_IMPORTANT, "Attempt to open socket for EUI retrieval failed: " << xstrerror());
+        clear();
+        return false;
+    }
 
     /* Set up structures for ARP lookup with blank interface name */
     struct arpreq arpReq;