diff options
author | Kurt Van Dijck <kurt.van.dijck@eia.be> | 2011-01-15 23:56:42 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2011-01-15 23:56:42 -0500 |
commit | 5e5073280379d38e86ade471daa7443b553fc839 (patch) | |
tree | 18b76f530ec22b57b36de68b985ad32444066dcc /net | |
parent | d78c68efa84ff312f3663dbf921b1e3485232205 (diff) |
can: test size of struct sockaddr in sendmsg
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>
Diffstat (limited to 'net')
-rw-r--r-- | net/can/bcm.c | 3 | ||||
-rw-r--r-- | net/can/raw.c | 3 |
2 files changed, 6 insertions, 0 deletions
diff --git a/net/can/bcm.c b/net/can/bcm.c index 9d5e8accfab1..092dc88a7c64 100644 --- a/net/can/bcm.c +++ b/net/can/bcm.c | |||
@@ -1256,6 +1256,9 @@ static int bcm_sendmsg(struct kiocb *iocb, struct socket *sock, | |||
1256 | struct sockaddr_can *addr = | 1256 | struct sockaddr_can *addr = |
1257 | (struct sockaddr_can *)msg->msg_name; | 1257 | (struct sockaddr_can *)msg->msg_name; |
1258 | 1258 | ||
1259 | if (msg->msg_namelen < sizeof(*addr)) | ||
1260 | return -EINVAL; | ||
1261 | |||
1259 | if (addr->can_family != AF_CAN) | 1262 | if (addr->can_family != AF_CAN) |
1260 | return -EINVAL; | 1263 | return -EINVAL; |
1261 | 1264 | ||
diff --git a/net/can/raw.c b/net/can/raw.c index e88f610fdb7b..883e9d74fddf 100644 --- a/net/can/raw.c +++ b/net/can/raw.c | |||
@@ -649,6 +649,9 @@ static int raw_sendmsg(struct kiocb *iocb, struct socket *sock, | |||
649 | struct sockaddr_can *addr = | 649 | struct sockaddr_can *addr = |
650 | (struct sockaddr_can *)msg->msg_name; | 650 | (struct sockaddr_can *)msg->msg_name; |
651 | 651 | ||
652 | if (msg->msg_namelen < sizeof(*addr)) | ||
653 | return -EINVAL; | ||
654 | |||
652 | if (addr->can_family != AF_CAN) | 655 | if (addr->can_family != AF_CAN) |
653 | return -EINVAL; | 656 | return -EINVAL; |
654 | 657 | ||