summaryrefslogtreecommitdiff
path: root/drivers/net/af_packet
diff options
context:
space:
mode:
authorFerruh Yigit <ferruh.yigit@intel.com>2017-05-04 12:16:59 +0100
committerThomas Monjalon <thomas@monjalon.net>2017-05-05 17:52:55 +0200
commit131fe443469f1de5fda3614e20077fad93eae907 (patch)
treed2a6316c7acce8ee47c0d4ed1b301cc779ac3417 /drivers/net/af_packet
parent6839dae96c264a5c3f343f28977997532e5d0a44 (diff)
downloaddpdk-next-eventdev-131fe443469f1de5fda3614e20077fad93eae907.zip
dpdk-next-eventdev-131fe443469f1de5fda3614e20077fad93eae907.tar.gz
dpdk-next-eventdev-131fe443469f1de5fda3614e20077fad93eae907.tar.xz
net/af_packet: prefer snprintf against strncpy
strncpy may left destination buffer not NULL terminated, switched using snprintf to be sure destination buffer is NULL terminated. Coverity issue: 1407495 Coverity issue: 1407498 Fixes: cc68ac4847bc ("net/af_packet: support MTU change") Fixes: 218259590ea4 ("net/af_packet: support promiscuous") Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
Diffstat (limited to 'drivers/net/af_packet')
-rw-r--r--drivers/net/af_packet/rte_eth_af_packet.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/net/af_packet/rte_eth_af_packet.c b/drivers/net/af_packet/rte_eth_af_packet.c
index 6f6ba0c..68de45c 100644
--- a/drivers/net/af_packet/rte_eth_af_packet.c
+++ b/drivers/net/af_packet/rte_eth_af_packet.c
@@ -452,7 +452,7 @@ eth_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu)
if (s < 0)
return -EINVAL;
- strncpy(ifr.ifr_name, internals->if_name, IFNAMSIZ);
+ snprintf(ifr.ifr_name, IFNAMSIZ, "%s", internals->if_name);
ret = ioctl(s, SIOCSIFMTU, &ifr);
close(s);
@@ -472,7 +472,7 @@ eth_dev_change_flags(char *if_name, uint32_t flags, uint32_t mask)
if (s < 0)
return;
- strncpy(ifr.ifr_name, if_name, IFNAMSIZ);
+ snprintf(ifr.ifr_name, IFNAMSIZ, "%s", if_name);
if (ioctl(s, SIOCGIFFLAGS, &ifr) < 0)
goto out;
ifr.ifr_flags &= mask;