Fix using HOST_NOT_FOUND instead of EAI_NONAME.

HOST_NOT_FOUND is a gethostbyname(3) error condition rather than a
getaddrinfo(3) error condition and cannot be passed to net_gethosterror
as documented as it calls gai_strerror(3). EAI_NONAME is the appropriate
similar error condition as standardized by POSIX for getaddrinfo(3).
This commit is contained in:
Jonas 'Sortie' Termansen 2024-11-01 22:23:46 +01:00 committed by Ailin Nemui
parent 5a9a9ababa
commit f24d859c80

View File

@ -430,7 +430,7 @@ int net_gethostbyname(const char *addr, IPADDR *ip4, IPADDR *ip6)
}
if (count_v4 == 0 && count_v6 == 0)
return HOST_NOT_FOUND; /* shouldn't happen? */
return EAI_NONAME; /* shouldn't happen? */
/* if there are multiple addresses, return random one */
use_v4 = count_v4 <= 1 ? 0 : rand() % count_v4;