Skip to content
Snippets Groups Projects
Commit baa72abe authored by Deucе's avatar Deucе :ok_hand_tone4:
Browse files

Make inet_ptoaddr() not crash and work with IPv4 address strings

parent baa471f6
No related branches found
No related tags found
1 merge request!463MRC mods by Codefenix (2024-10-20)
Pipeline #2272 passed
...@@ -617,9 +617,11 @@ union xp_sockaddr* inet_ptoaddr(char *addr_str, union xp_sockaddr *addr, size_t ...@@ -617,9 +617,11 @@ union xp_sockaddr* inet_ptoaddr(char *addr_str, union xp_sockaddr *addr, size_t
if(getaddrinfo(addr_str, NULL, &hints, &res)) if(getaddrinfo(addr_str, NULL, &hints, &res))
return NULL; return NULL;
for(cur = res; cur; cur++) { for(cur = res; cur; cur = cur->ai_next) {
if(cur->ai_addr->sa_family == AF_INET6) if(cur->ai_addr->sa_family == AF_INET6)
break; break;
if(cur->ai_addr->sa_family == AF_INET)
break;
} }
if(!cur) { if(!cur) {
freeaddrinfo(res); freeaddrinfo(res);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment