From f67144614ce47a7037765727764c6d46dd000e86 Mon Sep 17 00:00:00 2001 From: Robert Mustacchi Date: Thu, 12 Jun 2014 06:33:36 +0000 Subject: [PATCH] 4931 kernel's inet_pton still botches v4 mapped and compat addresses byte order Reviewed by: Dan McDonald Reviewed by: Sebastien Roy Reviewed by: Yuri Pankov Approved by: Dan McDonald --- usr/src/uts/common/inet/ip/inet_ntop.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/usr/src/uts/common/inet/ip/inet_ntop.c b/usr/src/uts/common/inet/ip/inet_ntop.c index 9cd9b5e837..544e180c72 100644 --- a/usr/src/uts/common/inet/ip/inet_ntop.c +++ b/usr/src/uts/common/inet/ip/inet_ntop.c @@ -292,21 +292,27 @@ __inet_pton(int af, char *inp, void *outp, int compat) v6outp = (union v6buf_u *)outp; if (strchr_w(inp, '.') != NULL) { + int ret = 0; + /* v4 mapped or v4 compatable */ if (strncmp(inp, "::ffff:", 7) == 0) { ipaddr_t ipv4_all_zeroes = 0; /* mapped - first init prefix and then fill */ IN6_IPADDR_TO_V4MAPPED(ipv4_all_zeroes, &v6outp->v6addr_u); - return (str2inet_addr(inp + 7, - &(v6outp->v6addr_u.s6_addr32[3]))); + ret = str2inet_addr(inp + 7, + &(v6outp->v6addr_u.s6_addr32[3])); } else if (strncmp(inp, "::", 2) == 0) { /* v4 compatable - prefix all zeroes */ bzero(&v6outp->v6addr_u, sizeof (in6_addr_t)); - return (str2inet_addr(inp + 2, - &(v6outp->v6addr_u.s6_addr32[3]))); + ret = str2inet_addr(inp + 2, + &(v6outp->v6addr_u.s6_addr32[3])); } - return (0); + if (ret > 0 && !compat) { + v6outp->v6addr_u.s6_addr32[3] = + htonl(v6outp->v6addr_u.s6_addr32[3]); + } + return (ret); } for (i = 0; i < 8; i++) { int error; -- 2.11.4.GIT