]> git.baikalelectronics.ru Git - kernel.git/commit
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)
committerDavid S. Miller <davem@davemloft.net>
Thu, 13 Jun 2013 08:38:36 +0000 (01:38 -0700)
commitbeb96a4a788623a293deb729232c1ae9bac2697d
tree48d2bb80d960a20a12ebb2b5108c3e589605e26b
parente93e25abe72a097a53511f14dc4fbcf9bc7c16ab
packet: packet_getname_spkt: make sure string is always 0-terminated

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>
net/packet/af_packet.c