diff options
-rw-r--r-- | gr-blocks/lib/tuntap_pdu_impl.cc | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/gr-blocks/lib/tuntap_pdu_impl.cc b/gr-blocks/lib/tuntap_pdu_impl.cc index e333e40bdd..058fb6d26f 100644 --- a/gr-blocks/lib/tuntap_pdu_impl.cc +++ b/gr-blocks/lib/tuntap_pdu_impl.cc @@ -49,7 +49,7 @@ tuntap_pdu_impl::tuntap_pdu_impl(std::string dev, int MTU, bool istunflag) // make the tuntap char dev_cstr[1024]; memset(dev_cstr, 0x00, 1024); - strncpy(dev_cstr, dev.c_str(), std::min(sizeof(dev_cstr), dev.size())); + strncpy(dev_cstr, dev.c_str(), std::min(sizeof(dev_cstr) - 1, dev.size())); bool istun = d_istunflag; if (istun) { @@ -150,8 +150,7 @@ int tuntap_pdu_impl::set_mtu(const char* dev, int MTU) /* preparation of the struct ifr, of type "struct ifreq" */ memset(&ifr, 0, sizeof(ifr)); - strncpy(ifr.ifr_name, dev, IFNAMSIZ); - ifr.ifr_name[IFNAMSIZ - 1] = '\0'; + strncpy(ifr.ifr_name, dev, IFNAMSIZ - 1); ifr.ifr_addr.sa_family = AF_INET; /* address family */ ifr.ifr_mtu = MTU; |