]> err.no Git - linux-2.6/blobdiff - net/ipv6/ipv6_sockglue.c
Merge branch 'net-next-2.6-v6ready-20080703' of git://git.linux-ipv6.org/gitroot...
[linux-2.6] / net / ipv6 / ipv6_sockglue.c
index a9988841172af06fbd6ec6f4e754bbc51cda30f9..030c0c956f9db6d9aa1411c825d07bab00b32c0f 100644 (file)
@@ -343,18 +343,21 @@ static int do_ipv6_setsockopt(struct sock *sk, int level, int optname,
        case IPV6_DSTOPTS:
        {
                struct ipv6_txoptions *opt;
+
+               /* remove any sticky options header with a zero option
+                * length, per RFC3542.
+                */
                if (optlen == 0)
                        optval = NULL;
+               else if (optlen < sizeof(struct ipv6_opt_hdr) ||
+                        optlen & 0x7 || optlen > 8 * 255)
+                       goto e_inval;
 
                /* hop-by-hop / destination options are privileged option */
                retv = -EPERM;
                if (optname != IPV6_RTHDR && !capable(CAP_NET_RAW))
                        break;
 
-               if (optlen < sizeof(struct ipv6_opt_hdr) ||
-                   optlen & 0x7 || optlen > 8 * 255)
-                       goto e_inval;
-
                opt = ipv6_renew_options(sk, np->opt, optname,
                                         (struct ipv6_opt_hdr __user *)optval,
                                         optlen);