Print this page
4596 Callers of ip_srcid_find_id() need to be more careful
        
@@ -22,10 +22,11 @@
 /*
  * Copyright (c) 1991, 2010, Oracle and/or its affiliates. All rights reserved.
  * Copyright (c) 2011, Joyent Inc. All rights reserved.
  * Copyright (c) 2011 Nexenta Systems, Inc. All rights reserved.
  * Copyright (c) 2013 by Delphix. All rights reserved.
+ * Copyright 2014, OmniTI Computer Consulting, Inc. All rights reserved.
  */
 /* Copyright (c) 1990 Mentat Inc. */
 
 #include <sys/types.h>
 #include <sys/stream.h>
@@ -1581,12 +1582,15 @@
                 *dstaddrp = dstaddr;
         }
 
         /* Handle __sin6_src_id if socket not bound to an IP address */
         if (srcid != 0 && connp->conn_laddr_v4 == INADDR_ANY) {
-                ip_srcid_find_id(srcid, &connp->conn_laddr_v6,
-                    IPCL_ZONEID(connp), tcps->tcps_netstack);
+                if (!ip_srcid_find_id(srcid, &connp->conn_laddr_v6,
+                    IPCL_ZONEID(connp), B_TRUE, tcps->tcps_netstack)) {
+                        /* Mismatch - conn_laddr_v6 would be v6 address. */
+                        return (EADDRNOTAVAIL);
+                }
                 connp->conn_saddr_v6 = connp->conn_laddr_v6;
         }
 
         IN6_IPADDR_TO_V4MAPPED(dstaddr, &connp->conn_faddr_v6);
         connp->conn_fport = dstport;
@@ -1663,12 +1667,15 @@
         if (IN6_IS_ADDR_UNSPECIFIED(dstaddrp))
                 *dstaddrp = ipv6_loopback;
 
         /* Handle __sin6_src_id if socket not bound to an IP address */
         if (srcid != 0 && IN6_IS_ADDR_UNSPECIFIED(&connp->conn_laddr_v6)) {
-                ip_srcid_find_id(srcid, &connp->conn_laddr_v6,
-                    IPCL_ZONEID(connp), tcps->tcps_netstack);
+                if (!ip_srcid_find_id(srcid, &connp->conn_laddr_v6,
+                    IPCL_ZONEID(connp), B_FALSE, tcps->tcps_netstack)) {
+                        /* Mismatch - conn_laddr_v6 would be v4-mapped. */
+                        return (EADDRNOTAVAIL);
+                }
                 connp->conn_saddr_v6 = connp->conn_laddr_v6;
         }
 
         /*
          * Take care of the scope_id now.