Avoid NULL pointer dereference
authorSepherosa Ziehau <sephe@dragonflybsd.org>
Tue, 2 Dec 2008 13:27:37 +0000 (21:27 +0800)
committerSepherosa Ziehau <sephe@dragonflybsd.org>
Tue, 2 Dec 2008 13:39:53 +0000 (21:39 +0800)
sys/netinet6/ip6_output.c

index 111e5c3..d1c018a 100644 (file)
@@ -2917,11 +2917,12 @@ ip6_setpktoption(int optname, u_char *buf, int len, struct ip6_pktopts *opt,
                         return (ENXIO);
                }
                /*
-                       * Check if the requested source address is indeed a
-                       * unicast address assigned to the node, and can be
-                       * used as the packet's source address.
-               */
-               if (!IN6_IS_ADDR_UNSPECIFIED(&opt->ip6po_pktinfo->ipi6_addr)) {
+                * Check if the requested source address is indeed a
+                * unicast address assigned to the node, and can be
+                * used as the packet's source address.
+                */
+               if (opt->ip6po_pktinfo != NULL &&
+                   !IN6_IS_ADDR_UNSPECIFIED(&opt->ip6po_pktinfo->ipi6_addr)) {
                        struct in6_ifaddr *ia6;
                        struct sockaddr_in6 sin6;