]> www.infradead.org Git - users/dwmw2/linux.git/commit
selftests/net: in timestamping, strncpy needs to preserve null byte
authortannerlove <tannerlove@google.com>
Mon, 8 Jun 2020 19:37:15 +0000 (15:37 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 24 Jun 2020 15:49:07 +0000 (17:49 +0200)
commit394869c49ff5eee34dc05f19a8b5d7c100d415c7
treed31f594c3b4636eed61117d85019bd014ef989c5
parent455fd835e4f7c241727f41a142e29f44f46b290b
selftests/net: in timestamping, strncpy needs to preserve null byte

[ Upstream commit 8027bc0307ce59759b90679fa5d8b22949586d20 ]

If user passed an interface option longer than 15 characters, then
device.ifr_name and hwtstamp.ifr_name became non-null-terminated
strings. The compiler warned about this:

timestamping.c:353:2: warning: ‘strncpy’ specified bound 16 equals \
destination size [-Wstringop-truncation]
  353 |  strncpy(device.ifr_name, interface, sizeof(device.ifr_name));

Fixes: cb9eff097831 ("net: new user space API for time stamping of incoming and outgoing packets")
Signed-off-by: Tanner Love <tannerlove@google.com>
Acked-by: Willem de Bruijn <willemb@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
tools/testing/selftests/net/timestamping.c