[core] avoid freeaddrinfo() on NULL ptr (fixes #2984)

getaddrinfo() should return non-empty result list (res)
or else should return EAI_NONAME or some other error

(musl C library does not check for NULL argument to freeaddrinfo())

  "Segmentation fault in mod_extforward with libmusl"
Glenn Strauss 2019-09-28 19:16:18 -04:00
parent 5c3f439bcf
commit 851728c6a1
1 changed files with 2 additions and 1 deletions

View File

@ -594,11 +594,12 @@ int sock_addr_from_str_numeric(server *srv, sock_addr *saddr, const char *str)
log_error_write(srv, __FILE__, __LINE__, "SSSs(S)",
"could not parse ip address ", str, " because ",
gai_strerror(result), strerror(errno));
return result;
} else if (addrlist == NULL) {
log_error_write(srv, __FILE__, __LINE__, "SSS",
"Problem in parsing ip address ", str,
": succeeded, but no information returned");
result = -1;
return -1;
} else switch (addrlist->ai_family) {
case AF_INET:
memcpy(&saddr->ipv4, addrlist->ai_addr, sizeof(saddr->ipv4));