logger: fix memory leak and use-after-free

This one call to getaddrinfo() did not adhere to the common idiom
of storing the result into a second res0 variable, which is later freed.

Reported by:	Coverity
CID:		1368069 1368071
Sponsored by:	Dell EMC
This commit is contained in:
Eric van Gyzen 2018-05-28 02:40:06 +00:00
parent f5136f7ecc
commit 488ee96b85
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=334270

View File

@ -298,7 +298,7 @@ socksetup(const char *src, const char *dst, const char *svcname,
error = getaddrinfo(dst, svcname, &hints, &res0);
if (error == EAI_SERVICE) {
warnx("%s/udp: unknown service", svcname);
error = getaddrinfo(dst, "514", &hints, &res);
error = getaddrinfo(dst, "514", &hints, &res0);
}
if (error)
errx(1, "%s: %s", gai_strerror(error), dst);