From 488ee96b85c2f81631cdeffbdab941570f9b4ab8 Mon Sep 17 00:00:00 2001 From: Eric van Gyzen Date: Mon, 28 May 2018 02:40:06 +0000 Subject: [PATCH] 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 --- usr.bin/logger/logger.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/usr.bin/logger/logger.c b/usr.bin/logger/logger.c index 71cc5fbb7aa..936bfc98803 100644 --- a/usr.bin/logger/logger.c +++ b/usr.bin/logger/logger.c @@ -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);