ipv4: check optlen for IP_MULTICAST_IF option
[linux-block.git] / net / ipv4 / ip_sockglue.c
index fc7993e9061fd855d1cb34b42fa491c49dcd669d..5a0693576e821c628edfb3f436243a0f8b107d4a 100644 (file)
@@ -611,6 +611,9 @@ static int do_ip_setsockopt(struct sock *sk, int level,
                 *      Check the arguments are allowable
                 */
 
+               if (optlen < sizeof(struct in_addr))
+                       goto e_inval;
+
                err = -EFAULT;
                if (optlen >= sizeof(struct ip_mreqn)) {
                        if (copy_from_user(&mreq, optval, sizeof(mreq)))