Browse Source

Fix url_from_socket to work with IPV6 sized names

master
Con Kolivas 9 years ago
parent
commit
3f83abab8d
  1. 9
      src/libckpool.c

9
src/libckpool.c

@ -570,14 +570,15 @@ out:
* INET6_ADDRSTRLEN size, port at least a string of 6 bytes */ * INET6_ADDRSTRLEN size, port at least a string of 6 bytes */
bool url_from_socket(const int sockd, char *url, char *port) bool url_from_socket(const int sockd, char *url, char *port)
{ {
socklen_t addrlen = sizeof(struct sockaddr); struct sockaddr_storage storage;
struct sockaddr addr; socklen_t addrlen = sizeof(struct sockaddr_storage);
struct sockaddr *addr = (struct sockaddr *)&storage;
if (sockd < 1) if (sockd < 1)
return false; return false;
if (getsockname(sockd, &addr, &addrlen)) if (getsockname(sockd, addr, &addrlen))
return false; return false;
if (!url_from_sockaddr(&addr, url, port)) if (!url_from_sockaddr(addr, url, port))
return false; return false;
return true; return true;
} }

Loading…
Cancel
Save