can: introduce CAN_REQUIRED_SIZE macro
The size of this structure will be increased with J1939 support. To stay binary compatible, the CAN_REQUIRED_SIZE macro is introduced for existing CAN protocols. Signed-off-by: Kurt Van Dijck <dev.kurt@vandijck-laurijssen.be> Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de> Acked-by: Oliver Hartkopp <socketcan@hartkopp.net> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
This commit is contained in:

committed by
Marc Kleine-Budde

parent
4f746fb495
commit
9868b5d44f
@@ -396,7 +396,7 @@ static int raw_bind(struct socket *sock, struct sockaddr *uaddr, int len)
|
||||
int err = 0;
|
||||
int notify_enetdown = 0;
|
||||
|
||||
if (len < sizeof(*addr))
|
||||
if (len < CAN_REQUIRED_SIZE(*addr, can_ifindex))
|
||||
return -EINVAL;
|
||||
if (addr->can_family != AF_CAN)
|
||||
return -EINVAL;
|
||||
@@ -733,7 +733,7 @@ static int raw_sendmsg(struct socket *sock, struct msghdr *msg, size_t size)
|
||||
if (msg->msg_name) {
|
||||
DECLARE_SOCKADDR(struct sockaddr_can *, addr, msg->msg_name);
|
||||
|
||||
if (msg->msg_namelen < sizeof(*addr))
|
||||
if (msg->msg_namelen < CAN_REQUIRED_SIZE(*addr, can_ifindex))
|
||||
return -EINVAL;
|
||||
|
||||
if (addr->can_family != AF_CAN)
|
||||
|
Reference in New Issue
Block a user