- Fix dereference of NULL pointer which could cause a crash [1]

- Fix memory leak due to lack of freeaddrinfo() [2]

CID:	1018281 [1]
CID:	1225057 [2]
MFC after:	3 days
This commit is contained in:
Hiroki Sato 2017-01-12 18:44:58 +00:00
parent eae0fba453
commit c10340d440
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=311994

View File

@ -684,6 +684,7 @@ init(void)
/*NOTREACHED*/ /*NOTREACHED*/
} }
#endif #endif
freeaddrinfo(res);
memset(&hints, 0, sizeof(hints)); memset(&hints, 0, sizeof(hints));
hints.ai_family = PF_INET6; hints.ai_family = PF_INET6;
@ -699,6 +700,7 @@ init(void)
/*NOTREACHED*/ /*NOTREACHED*/
} }
memcpy(&ripsin, res->ai_addr, res->ai_addrlen); memcpy(&ripsin, res->ai_addr, res->ai_addrlen);
freeaddrinfo(res);
#ifdef HAVE_POLL_H #ifdef HAVE_POLL_H
set[0].fd = ripsock; set[0].fd = ripsock;
@ -788,10 +790,17 @@ ripflush(struct ifc *ifcp, struct sockaddr_in6 *sin6, int nrt, struct netinfo6 *
error = sendpacket(sin6, RIPSIZE(nrt)); error = sendpacket(sin6, RIPSIZE(nrt));
if (error == EAFNOSUPPORT) { if (error == EAFNOSUPPORT) {
/* Protocol not supported */ /* Protocol not supported */
tracet(1, "Could not send info to %s (%s): " if (ifcp != NULL) {
"set IFF_UP to 0\n", tracet(1, "Could not send info to %s (%s): "
ifcp->ifc_name, inet6_n2p(&ifcp->ifc_ripsin.sin6_addr)); "set IFF_UP to 0\n",
ifcp->ifc_flags &= ~IFF_UP; /* As if down for AF_INET6 */ ifcp->ifc_name,
inet6_n2p(&ifcp->ifc_ripsin.sin6_addr));
/* As if down for AF_INET6 */
ifcp->ifc_flags &= ~IFF_UP;
} else {
tracet(1, "Could not send info to %s\n",
inet6_n2p(&sin6->sin6_addr));
}
} }
} }