From c3e14a350a3060e50cfa5656f04d24cf50fd0e13 Mon Sep 17 00:00:00 2001 From: Amos Jeffries Date: Wed, 21 Nov 2012 04:18:46 -0700 Subject: [PATCH] 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 --- src/eui/Eui48.cc | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/eui/Eui48.cc b/src/eui/Eui48.cc index a96561a749..c151feb6d6 100644 --- a/src/eui/Eui48.cc +++ b/src/eui/Eui48.cc @@ -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; -- 2.47.3