Skip to content

Commit

Permalink
can: test size of struct sockaddr in sendmsg
Browse files Browse the repository at this point in the history
This patch makes the CAN socket code conform to the manpage of sendmsg.

Signed-off-by: Kurt Van Dijck <[email protected]>
Acked-by: Oliver Hartkopp <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
Kurt Van Dijck authored and davem330 committed Jan 16, 2011
1 parent d78c68e commit 5e50732
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions net/can/bcm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
3 changes: 3 additions & 0 deletions net/can/raw.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit 5e50732

Please sign in to comment.