summaryrefslogtreecommitdiff
path: root/src/dev/net/ethertap.cc
diff options
context:
space:
mode:
authorSiddhesh Poyarekar <siddhesh.poyarekar@gmail.com>2018-02-19 00:28:12 +0530
committerSiddhesh Poyarekar <siddhesh.poyarekar@gmail.com>2018-03-06 19:45:34 +0000
commit10796633e84fc513ea820020ec17271edba82c4f (patch)
treee8faa7764695c27f479b80e12364d25c98ede9d5 /src/dev/net/ethertap.cc
parent5c3983215a2bd27545e8500baddc0567c26783bf (diff)
downloadgem5-10796633e84fc513ea820020ec17271edba82c4f.tar.xz
dev: Leave last byte in strncpy for NULL
The length of the strncpy should be one less than the destination to ensure that there is space for the last NULL byte in case the source is longer than the destination. Change-Id: Iea65fa6327c8242bd8ddf4bf9a5a2b5164996495 Signed-off-by: Siddhesh Poyarekar <siddhesh.poyarekar@gmail.com> Reviewed-on: https://gem5-review.googlesource.com/8561 Reviewed-by: Gabe Black <gabeblack@google.com> Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com> Maintainer: Andreas Sandberg <andreas.sandberg@arm.com>
Diffstat (limited to 'src/dev/net/ethertap.cc')
-rw-r--r--src/dev/net/ethertap.cc2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/dev/net/ethertap.cc b/src/dev/net/ethertap.cc
index 4b5b9bdb0..ca19b4884 100644
--- a/src/dev/net/ethertap.cc
+++ b/src/dev/net/ethertap.cc
@@ -404,7 +404,7 @@ EtherTap::EtherTap(const Params *p) : EtherTapBase(p)
struct ifreq ifr;
memset(&ifr, 0, sizeof(ifr));
ifr.ifr_flags = IFF_TAP | IFF_NO_PI;
- strncpy(ifr.ifr_name, p->tap_device_name.c_str(), IFNAMSIZ);
+ strncpy(ifr.ifr_name, p->tap_device_name.c_str(), IFNAMSIZ - 1);
if (ioctl(fd, TUNSETIFF, (void *)&ifr) < 0)
panic("Failed to access tap device %s.\n", ifr.ifr_name);