]> 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>
Wed, 21 Nov 2012 11:18:46 +0000 (04:18 -0700)
committerAmos Jeffries <squid3@treenet.co.nz>
Wed, 21 Nov 2012 11:18:46 +0000 (04:18 -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 a96561a74961cde33d199324ba29f19b85ddda46..c151feb6d64a6f0f12c3741a42d31f5fe9eafdcc 100644 (file)
@@ -173,6 +173,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
@@ -312,6 +317,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;