inet6: Only allow setting IPV6_V6ONLY sockopt to 1. master
authorSepherosa Ziehau <sephe@dragonflybsd.org>
Thu, 18 Dec 2014 12:46:53 +0000 (20:46 +0800)
committerSepherosa Ziehau <sephe@dragonflybsd.org>
Fri, 19 Dec 2014 02:01:01 +0000 (10:01 +0800)
sys/netinet6/ip6_output.c

index 8710888..70dd9ed 100644 (file)
@@ -1598,11 +1598,13 @@ do { \
                                                error = EINVAL;
                                                break;
                                        }
-                                       OPTSET(IN6P_IPV6_V6ONLY);
-                                       if (optval)
+                                       if (optval) {
+                                               in6p->in6p_flags |= IN6P_IPV6_V6ONLY;
                                                in6p->in6p_vflag &= ~INP_IPV4;
-                                       else
-                                               in6p->in6p_vflag |= INP_IPV4;
+                                       } else {
+                                               /* Don't allow v4-mapped */
+                                               error = EOPNOTSUPP;
+                                       }
                                        break;
                                }
                                break;