packet: packet_getname_spkt: make sure string is always 0-terminated
authorDaniel Borkmann <dborkman@redhat.com>
Wed, 12 Jun 2013 14:02:27 +0000 (16:02 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 27 Jun 2013 18:27:33 +0000 (11:27 -0700)
commit991e73ccb5a0499588565dd8b9fd06c4bd6bce81
treebd29973701fac5c6ce61ed9043f09e886d195260
parenta50ebefd35d237b3a6112e5fbea6d55e7ae4b509
packet: packet_getname_spkt: make sure string is always 0-terminated

[ Upstream commit 2dc85bf323515e59e15dfa858d1472bb25cad0fe ]

uaddr->sa_data is exactly of size 14, which is hard-coded here and
passed as a size argument to strncpy(). A device name can be of size
IFNAMSIZ (== 16), meaning we might leave the destination string
unterminated. Thus, use strlcpy() and also sizeof() while we're
at it. We need to memset the data area beforehand, since strlcpy
does not padd the remaining buffer with zeroes for user space, so
that we do not possibly leak anything.

Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
net/packet/af_packet.c