From: ljsebald <ljs...@us...> - 2023-11-13 03:07:21
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "A pseudo Operating System for the Dreamcast.". The branch, master has been updated via a5a79598ba4bf76fc85a66b267eeeedf8cf6d10a (commit) from e3b95d9f59db2326486f309771490479e71e05ba (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit a5a79598ba4bf76fc85a66b267eeeedf8cf6d10a Author: Heel <429...@us...> Date: Mon Nov 13 12:06:04 2023 +0900 Ensure getaddrinfo() handles IP adddress inputs without using DNS (#358) * Ensure getaddrinfo() handles IP adddress inputs without sending them to resolve over DNS ----------------------------------------------------------------------- Summary of changes: kernel/libc/koslib/getaddrinfo.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/kernel/libc/koslib/getaddrinfo.c b/kernel/libc/koslib/getaddrinfo.c index eff2466..4950c9c 100644 --- a/kernel/libc/koslib/getaddrinfo.c +++ b/kernel/libc/koslib/getaddrinfo.c @@ -706,6 +706,28 @@ int getaddrinfo(const char *nodename, const char *servname, return 0; } + /* Try to handle input as an IPv4 address */ + if(ihints.ai_family == AI_INET || ihints.ai_family == AF_UNSPEC) { + uint32_t ip4_addr; + + if(inet_pton(AF_INET, nodename, &ip4_addr) > 0) { + ihints.ai_family = AF_INET; + *res = add_ipv4_ai(ip4_addr, port, &ihints, NULL); + return 0; + } + } + + /* Try to handle input as an IPv6 address */ + if(ihints.ai_family == AF_INET6 || ihints.ai_family == AF_UNSPEC) { + struct in6_addr addr; + + if(inet_pton(AF_INET6, nodename, &addr.s6_addr) > 0) { + ihints.ai_family = AF_INET6; + *res = add_ipv6_ai(&addr, port, &ihints, NULL); + return 0; + } + } + /* If we've gotten this far, do the lookup. */ if(ihints.ai_family == AF_UNSPEC) { /* It seems that some resolvers really don't like multi-part questions. hooks/post-receive -- A pseudo Operating System for the Dreamcast. |