diff mbox

af_packet: use sizeof instead of constant in spkt_device

Message ID 4FD4EE90.1070302@iogearbox.net
State Accepted, archived
Delegated to: David Miller
Headers show

Commit Message

danborkmann@iogearbox.net June 10, 2012, 6:59 p.m. UTC
This small patch removes access to the last element of the spkt_device
array through a constant. Instead, it is accessed by sizeof() to respect
possible changes in if_packet.h.

Signed-off-by: Daniel Borkmann <daniel.borkmann@tik.ee.ethz.ch>
---
 net/packet/af_packet.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

David Miller June 11, 2012, 11:52 p.m. UTC | #1
From: Daniel Borkmann <danborkmann@iogearbox.net>
Date: Sun, 10 Jun 2012 20:59:28 +0200

> This small patch removes access to the last element of the spkt_device
> array through a constant. Instead, it is accessed by sizeof() to respect
> possible changes in if_packet.h.
> 
> Signed-off-by: Daniel Borkmann <daniel.borkmann@tik.ee.ethz.ch>

Applied, thanks.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
index 0f66174..06ff8e1 100644
--- a/net/packet/af_packet.c
+++ b/net/packet/af_packet.c
@@ -1476,7 +1476,7 @@  static int packet_sendmsg_spkt(struct kiocb *iocb, struct socket *sock,
 	 *	Find the device first to size check it
 	 */
 
-	saddr->spkt_device[13] = 0;
+	saddr->spkt_device[sizeof(saddr->spkt_device) - 1] = 0;
 retry:
 	rcu_read_lock();
 	dev = dev_get_by_name_rcu(sock_net(sk), saddr->spkt_device);