Skip to content

Commit

Permalink
Fix getaddrinfo for IPv6 loopback address (#22640)
Browse files Browse the repository at this point in the history
  • Loading branch information
sbc100 authored Oct 1, 2024
1 parent 0962b6c commit 3f6f7a9
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 4 deletions.
2 changes: 1 addition & 1 deletion src/library.js
Original file line number Diff line number Diff line change
Expand Up @@ -1073,7 +1073,7 @@ addToLibrary({
if (family === {{{ cDefs.AF_INET }}}) {
addr = _htonl({{{ cDefs.INADDR_LOOPBACK }}});
} else {
addr = [0, 0, 0, 1];
addr = [0, 0, 0, _htonl(1)];
}
}
ai = allocaddrinfo(family, type, proto, null, addr, port);
Expand Down
3 changes: 0 additions & 3 deletions test/sockets/test_getaddrinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,7 @@ int main() {
print_addrinfo(servinfo);
assert(servinfo->ai_family == AF_INET6);
assert(servinfo->ai_socktype == SOCK_STREAM);
#ifndef __EMSCRIPTEN__
// TODO(sbc): This assert currently fails under emscripten, but should not
assert(memcmp(&sa6->sin6_addr, &in6addr_loopback, sizeof(in6addr_loopback)) == 0);
#endif
assert(sa6->sin6_port == ntohs(81));
freeaddrinfo(servinfo);

Expand Down

0 comments on commit 3f6f7a9

Please sign in to comment.