1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 06:27:45 +00:00

LibC: Additional functionality for getaddrinfo()

When node is NULL and AI_PASSIVE is specified we are supposed to use
the "any" address, otherwise we should use the loopback address.
This commit is contained in:
Gunnar Beutner 2021-04-19 20:33:33 +02:00 committed by Andreas Kling
parent 38619a9f24
commit cd432860d8

View file

@ -667,6 +667,13 @@ int getaddrinfo(const char* __restrict node, const char* __restrict service, con
if (hints && hints->ai_family != AF_INET && hints->ai_family != AF_UNSPEC)
return EAI_FAMILY;
if (!node) {
if (hints && hints->ai_flags & AI_PASSIVE)
node = "0.0.0.0";
else
node = "127.0.0.1";
}
auto host_ent = gethostbyname(node);
if (!host_ent)
return EAI_FAIL;