Initialize nfmark value on Comm::Connections to zero. Memory is init by
MemPools functionality earlier, but not necessarily now.
Check for and produce error when getsockname() call fails to identify
a local IP address on inbound connections.
Detected by Coverity Scan. Issues 740543, 740320
peerType(HIER_NONE),
fd(-1),
tos(0),
+ nfmark(0),
flags(COMM_NONBLOCKING),
peer_(NULL)
{
// lookup the local-end details of this new connection
details->local.InitAddrInfo(gai);
details->local.SetEmpty();
- getsockname(sock, gai->ai_addr, &gai->ai_addrlen);
+ if (getsockname(sock, gai->ai_addr, &gai->ai_addrlen) != 0) {
+ debugs(50, DBG_IMPORTANT, "ERROR: getsockname() failed to locate local-IP on " << details << ": " << xstrerror());
+ details->local.FreeAddrInfo(gai);
+ return COMM_ERROR;
+ }
details->local = *gai;
details->local.FreeAddrInfo(gai);