summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Mustacchi <rm@joyent.com>2014-06-12 06:33:36 +0000
committerRobert Mustacchi <rm@joyent.com>2014-06-21 10:22:45 -0700
commitf67144614ce47a7037765727764c6d46dd000e86 (patch)
tree4202609d05f8845d6800453d6f7cfc430a21e330
parent09b0d01c5bc323b8ee7043100e09aded27cc12ab (diff)
downloadillumos-joyent-f67144614ce47a7037765727764c6d46dd000e86.tar.gz
4931 kernel's inet_pton still botches v4 mapped and compat addresses byte order
Reviewed by: Dan McDonald <danmcd@omniti.com> Reviewed by: Sebastien Roy <sebastien.roy@delphix.com> Reviewed by: Yuri Pankov <yuri.pankov@nexenta.com> Approved by: Dan McDonald <danmcd@omniti.com>
-rw-r--r--usr/src/uts/common/inet/ip/inet_ntop.c16
1 files 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;