can: test size of struct sockaddr in sendmsg
authorKurt Van Dijck <kurt.van.dijck@eia.be>
Sun, 16 Jan 2011 04:56:42 +0000 (20:56 -0800)
committerDavid S. Miller <davem@davemloft.net>
Sun, 16 Jan 2011 04:56:42 +0000 (20:56 -0800)
This patch makes the CAN socket code conform to the manpage of sendmsg.

Signed-off-by: Kurt Van Dijck <kurt.van.dijck@eia.be>
Acked-by: Oliver Hartkopp <socketcan@hartkopp.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/can/bcm.c
net/can/raw.c

index 9d5e8accfab1d73f25e8a00ae45523a400b820ce..092dc88a7c64c63856f91a32d4c5511471476eaa 100644 (file)
@@ -1256,6 +1256,9 @@ static int bcm_sendmsg(struct kiocb *iocb, struct socket *sock,
                struct sockaddr_can *addr =
                        (struct sockaddr_can *)msg->msg_name;
 
+               if (msg->msg_namelen < sizeof(*addr))
+                       return -EINVAL;
+
                if (addr->can_family != AF_CAN)
                        return -EINVAL;
 
index e88f610fdb7bb11e69cc1f5a0bf10846d5c7165c..883e9d74fddf6439b483f822b327371b78bb9670 100644 (file)
@@ -649,6 +649,9 @@ static int raw_sendmsg(struct kiocb *iocb, struct socket *sock,
                struct sockaddr_can *addr =
                        (struct sockaddr_can *)msg->msg_name;
 
+               if (msg->msg_namelen < sizeof(*addr))
+                       return -EINVAL;
+
                if (addr->can_family != AF_CAN)
                        return -EINVAL;