af_packet: use sizeof instead of constant in spkt_device
authordanborkmann@iogearbox.net <danborkmann@iogearbox.net>
Sun, 10 Jun 2012 08:59:28 +0000 (08:59 +0000)
committerDavid S. Miller <davem@davemloft.net>
Mon, 11 Jun 2012 23:51:51 +0000 (16:51 -0700)
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>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/packet/af_packet.c

index 71ac6559e0c66a47076fe79ce6668f850dbf4aa8..8a10d5b3c8320b4d4f705f4bc4cc7db21d415dbf 100644 (file)
@@ -1475,7 +1475,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);