diff options
author | Gunnar Beutner <gunnar@beutner.name> | 2021-04-19 20:33:33 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-04-19 21:00:23 +0200 |
commit | cd432860d85e8a98b6ab5e94b916293914006833 (patch) | |
tree | 611dbfa8897a91925c2bb598b19e2b062525941b /Userland | |
parent | 38619a9f24bbc5a64355e14842f1f54cc699d2a7 (diff) | |
download | serenity-cd432860d85e8a98b6ab5e94b916293914006833.zip |
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.
Diffstat (limited to 'Userland')
-rw-r--r-- | Userland/Libraries/LibC/netdb.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/Userland/Libraries/LibC/netdb.cpp b/Userland/Libraries/LibC/netdb.cpp index 7231a1ac69..cd43bb834b 100644 --- a/Userland/Libraries/LibC/netdb.cpp +++ b/Userland/Libraries/LibC/netdb.cpp @@ -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; |