summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorDaniel Wagner <daniel.wagner@bmw-carit.de>2013-11-22 13:26:47 +0100
committerPatrik Flykt <patrik.flykt@linux.intel.com>2013-11-27 08:53:53 +0200
commite6c7b221702c974d7f363f08d256248476ed3dd6 (patch)
tree088d09f19e66c085d791009813697fa5b0935cf6 /tools
parentf06685322f4c8a2e13cd817e4ee50fb5e15e7872 (diff)
downloadconnman-e6c7b221702c974d7f363f08d256248476ed3dd6.tar.gz
tap-test: Set device name with null termination
ifr_name is a null terminated buffer, therefore we should only copy IFNAMSIZ - 1 characters. Reported by coverity.
Diffstat (limited to 'tools')
-rw-r--r--tools/tap-test.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/tools/tap-test.c b/tools/tap-test.c
index 1074c9c9..fdc098aa 100644
--- a/tools/tap-test.c
+++ b/tools/tap-test.c
@@ -49,7 +49,7 @@ static int inet_ifup(const char *ifname)
return -errno;
memset(&ifr, 0, sizeof(ifr));
- strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
+ strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name) - 1);
if (ioctl(sk, SIOCGIFFLAGS, &ifr) < 0) {
err = -errno;
@@ -89,7 +89,7 @@ static int create_tap(const char *ifname)
memset(&ifr, 0, sizeof(ifr));
ifr.ifr_flags = IFF_TAP | IFF_NO_PI;
- strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
+ strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name) - 1);
if (ioctl(fd, TUNSETIFF, (void *) &ifr) < 0) {
perror("Failed to set TUN/TAP interface");