]> 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>
Sat, 24 Nov 2012 03:57:33 +0000 (20:57 -0700)
committerAmos Jeffries <squid3@treenet.co.nz>
Sat, 24 Nov 2012 03:57:33 +0000 (20:57 -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 57694d8192c4976eab415008fda81e2e705a715d..0ad019471a2d86ad38a6dfb382b62a09a0a77019 100644 (file)
@@ -176,6 +176,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
@@ -315,6 +320,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;