------------------------------------------------------------ revno: 11729 revision-id: squid3@treenet.co.nz-20121130133406-csamtn4v39n6f842 parent: squid3@treenet.co.nz-20121130133227-36b8n7bwwiv23tx8 committer: Amos Jeffries branch nick: 3.2 timestamp: Fri 2012-11-30 06:34:06 -0700 message: 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 ------------------------------------------------------------ # Bazaar merge directive format 2 (Bazaar 0.90) # revision_id: squid3@treenet.co.nz-20121130133406-csamtn4v39n6f842 # target_branch: http://bzr.squid-cache.org/bzr/squid3/branches\ # /SQUID_3_2 # testament_sha1: e05ef45226f61ce5cab851c636798f42669e213e # timestamp: 2012-11-30 13:41:48 +0000 # source_branch: http://bzr.squid-cache.org/bzr/squid3/branches\ # /SQUID_3_2 # base_revision_id: squid3@treenet.co.nz-20121130133227-\ # 36b8n7bwwiv23tx8 # # Begin patch === modified file 'src/eui/Eui48.cc' --- src/eui/Eui48.cc 2012-07-28 05:38:50 +0000 +++ src/eui/Eui48.cc 2012-11-30 13:34:06 +0000 @@ -174,6 +174,11 @@ /* 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 @@ /* 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;