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
This commit is contained in:
Jeffrey Altman
2022-09-16 13:48:55 -04:00
parent 76c110e1ef
commit 7b914bfb64

View File

@@ -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,
&current, const_v4, &v4_addr, NULL);
}
*res = first;
return 0;
return ret;
}
static int