[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20110115193916.GC463@e-circ.dyndns.org>
Date: Sat, 15 Jan 2011 20:39:16 +0100
From: Kurt Van Dijck <kurt.van.dijck@....be>
To: netdev@...r.kernel.org, socketcan-core@...ts.berlios.de,
Oliver Hartkopp <socketcan@...tkopp.net>
Subject: [PATCH v2] 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@....be>
Acked-by: Oliver Hartkopp <socketcan@...tkopp.net>
---
net/can/bcm.c | 3 +++
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 6faa825..2f804e4 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,
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;
diff --git a/net/can/raw.c b/net/can/raw.c
index e88f610..883e9d7 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,
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;
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists