Browse Source

[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())

x-ref:
  "Segmentation fault in mod_extforward with libmusl"
  https://redmine.lighttpd.net/issues/2984
personal/stbuehler/ci-build
Glenn Strauss 3 years ago
parent
commit
851728c6a1
  1. 3
      src/sock_addr.c

3
src/sock_addr.c

@ -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));

Loading…
Cancel
Save