From: Amos Jeffries Date: Sat, 24 Nov 2012 03:57:33 +0000 (-0700) Subject: libeui: Warn and fail nicely on socket errors looking up ARP record X-Git-Tag: SQUID_3_3_0_2~10 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bf170041c2f5e1786030260cec6d0379ce525e60;p=thirdparty%2Fsquid.git libeui: Warn and fail nicely on socket errors looking up ARP record 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 --- diff --git a/src/eui/Eui48.cc b/src/eui/Eui48.cc index 57694d8192..0ad019471a 100644 --- a/src/eui/Eui48.cc +++ b/src/eui/Eui48.cc @@ -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;