Commit c5a91aa5 authored by Mike Frysinger's avatar Mike Frysinger

lib: inet6: clean up INET6_print a bit

There's no need to cast the char* to a struct in6_addr*, so delete
that logic.

Switch the hardcoded 80 limit to the INET6_ADDRSTRLEN constant.

Make sure the buffer we pass into inet_ntop is always NUL terminated.
parent fd10bbeb
......@@ -126,10 +126,11 @@ static void INET6_reserror(const char *text)
/* Display an Internet socket address. */
static const char *INET6_print(const char *ptr)
{
static char name[80];
inet_ntop(AF_INET6, (struct in6_addr *) ptr, name, 80);
return fix_v4_address(name, (struct in6_addr *)ptr);
static char name[INET6_ADDRSTRLEN + 1];
socklen_t len = sizeof(name) - 1;
name[len] = '\0';
inet_ntop(AF_INET6, ptr, name, len);
return fix_v4_address(name, (struct in6_addr *)ptr);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment