From 7b914bfb645a12057024966e79ddbb240b7cdca6 Mon Sep 17 00:00:00 2001 From: Jeffrey Altman Date: Fri, 16 Sep 2022 13:48:55 -0400 Subject: [PATCH] roken: getaddrinfo get_null return errors get_null() can fail for two reasons. There can be a memory allocation issue or the hints->ai_family could be unsupported. This change informs the caller of the error state instead of returning success with an invalid struct addrinfo output parameter. Fixes #1007 Reported-by: opless --- lib/roken/getaddrinfo.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/roken/getaddrinfo.c b/lib/roken/getaddrinfo.c index 12a26a712..47affba59 100644 --- a/lib/roken/getaddrinfo.c +++ b/lib/roken/getaddrinfo.c @@ -188,7 +188,7 @@ get_null (const struct addrinfo *hints, struct addrinfo *first = NULL; struct addrinfo **current = &first; int family = PF_UNSPEC; - int ret; + int ret = EAI_FAMILY; if (hints != NULL) family = hints->ai_family; @@ -216,7 +216,7 @@ get_null (const struct addrinfo *hints, ¤t, const_v4, &v4_addr, NULL); } *res = first; - return 0; + return ret; } static int