DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] net/af_packet: prefer snprintf against strncpy
@ 2017-05-04 11:16 Ferruh Yigit
  2017-05-05 15:59 ` Thomas Monjalon
  0 siblings, 1 reply; 2+ messages in thread
From: Ferruh Yigit @ 2017-05-04 11:16 UTC (permalink / raw)
  To: John W. Linville; +Cc: dev, Ferruh Yigit, Chas Williams

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>
---
Cc: Chas Williams <ciwillia@brocade.com>
---
 drivers/net/af_packet/rte_eth_af_packet.c | 4 ++--
 1 file 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;
-- 
2.9.3

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [dpdk-dev] [PATCH] net/af_packet: prefer snprintf against strncpy
  2017-05-04 11:16 [dpdk-dev] [PATCH] net/af_packet: prefer snprintf against strncpy Ferruh Yigit
@ 2017-05-05 15:59 ` Thomas Monjalon
  0 siblings, 0 replies; 2+ messages in thread
From: Thomas Monjalon @ 2017-05-05 15:59 UTC (permalink / raw)
  To: Ferruh Yigit; +Cc: dev, John W. Linville, Chas Williams

04/05/2017 13:16, Ferruh Yigit:
> 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>

Applied, thanks

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-05-05 15:59 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-04 11:16 [dpdk-dev] [PATCH] net/af_packet: prefer snprintf against strncpy Ferruh Yigit
2017-05-05 15:59 ` Thomas Monjalon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).