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)
committerBen Hutchings <ben@decadent.org.uk>
Sat, 29 Jun 2013 03:06:42 +0000 (04:06 +0100)
commit4f5a75542dff85553a5b2bd2f38e2fe02bca0577
tree4e13ceb770dbe498268f3b757595a049ca4f5480
parente3d40c6172e2ae213c47acbc01b7cb7d64d4ac3e
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: Ben Hutchings <ben@decadent.org.uk>
net/packet/af_packet.c