diff options
author | Alekh Gupta <alekhgupta1441@gmail.com> | 2020-05-02 18:30:47 +0530 |
---|---|---|
committer | mormj <34754695+mormj@users.noreply.github.com> | 2020-05-05 13:17:37 -0400 |
commit | bfeef69cc9bdec8e721e07b444392708098cfb90 (patch) | |
tree | 5c662dc5ae4fefbde9cb4fee2aac52e573f1656a /gr-blocks | |
parent | 613ad6900db6b66248a7a497c22e9c277d7e238e (diff) |
gr-blocks: Updated tuntap_pdu_impl.cc to fix strncpy warning
Diffstat (limited to 'gr-blocks')
-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; |