human_addr2(): only attempt to parse INET addresses

This commit is contained in:
Nikos Mavrogiannopoulos
2015-08-25 12:48:44 +02:00
parent 91926c3d57
commit f63e0cf65e

View File

@@ -40,6 +40,10 @@ char *human_addr2(const struct sockaddr *sa, socklen_t salen,
if (!buf || !buflen)
return NULL;
if (sa->sa_family != AF_INET && sa->sa_family != AF_INET6) {
return NULL;
}
if (full != 0 && salen == sizeof(struct sockaddr_in6) &&
((struct sockaddr_in6*)sa)->sin6_port != 0) {
*buf = '[';