getaddrinfo: fix behaviour when node is null and !passive

according to the spec, if these 2 conditions hold, the name shall
resolve to localhost.

closes #292
pull/307/head
rofl0r 2019-07-21 14:27:55 +01:00
parent de4460fbd1
commit 962373e5c6
1 changed files with 4 additions and 0 deletions

View File

@ -879,6 +879,10 @@ int proxy_getaddrinfo(const char *node, const char *service, const struct addrin
goto err2;
} else if(node) {
af = ((struct sockaddr_in *) &space->sockaddr_space)->sin_family;
} else if(!node && !(hints->ai_flags & AI_PASSIVE)) {
af = ((struct sockaddr_in *) &space->sockaddr_space)->sin_family = AF_INET;
memcpy(&((struct sockaddr_in *) &space->sockaddr_space)->sin_addr,
(char[]){127,0,0,1}, 4);
}
if(service) mygetservbyname_r(service, NULL, &se_buf, buf, sizeof(buf), &se);