File tree Expand file tree Collapse file tree 1 file changed +8
-0
lines changed
libctru/source/services/soc Expand file tree Collapse file tree 1 file changed +8
-0
lines changed Original file line number Diff line number Diff line change @@ -53,6 +53,14 @@ static struct addrinfo * buffer2addrinfo(addrinfo_3ds_t * entry)
5353
5454 memcpy (ai -> ai_canonname , entry -> ai_canonname , ai_canonname_len );
5555 memcpy (ai -> ai_addr , & entry -> ai_addr , ai -> ai_addrlen );
56+
57+ // the sizes of hos-native sock_addr_in and the one we expose from libc are not the same
58+ // because the libc one has a `sin_zero` member for better compatibility with linux
59+ // it is located at the tail of the structure and will be zero-initilized due to use of `calloc` above
60+ // so it is fine that we did not `memcpy` anything into it above
61+ if (ai -> ai_family == AF_INET )
62+ ai -> ai_addrlen = sizeof (struct sockaddr_in );
63+
5664 ai -> ai_addr -> sa_family = ntohs (ai -> ai_addr -> sa_family ) & 0xFF ; // Clear sa_len to match the API
5765 }
5866 return ai ;
You can’t perform that action at this time.
0 commit comments