DPDK patches and discussions
 help / color / mirror / Atom feed
From: Kirill Rybalchenko <kirill.rybalchenko@intel.com>
To: dev@dpdk.org
Cc: kirill.rybalchenko@intel.com, andrey.chilikin@intel.com,
	beilei.xing@intel.com, jingjing.wu@intel.com
Subject: [dpdk-dev] [PATCH] net/i40e: fix unsecure usage of strncpy function
Date: Tue, 24 Oct 2017 10:22:38 +0100	[thread overview]
Message-ID: <1508836958-76512-1-git-send-email-kirill.rybalchenko@intel.com> (raw)
In-Reply-To: <1508757889-40845-1-git-send-email-kirill.rybalchenko@intel.com>

Use more secure snprintf function instead of strncpy
to prevent memory access violation.

Fixes: 40d1324423a4 ("net/i40e: get ddp profile protocol info")

Signed-off-by: Kirill Rybalchenko <kirill.rybalchenko@intel.com>
---
 drivers/net/i40e/rte_pmd_i40e.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/i40e/rte_pmd_i40e.c b/drivers/net/i40e/rte_pmd_i40e.c
index 4881ea0..3df4dcc 100644
--- a/drivers/net/i40e/rte_pmd_i40e.c
+++ b/drivers/net/i40e/rte_pmd_i40e.c
@@ -1927,8 +1927,8 @@ int rte_pmd_i40e_get_ddp_info(uint8_t *pkg_buff, uint32_t pkg_size,
 		tlv = (struct i40e_profile_tlv_section_record *)&proto[1];
 		for (i = j = 0; i < nb_rec; j++) {
 			pinfo[j].proto_id = tlv->data[0];
-			strncpy(pinfo[j].name, (const char *)&tlv->data[1],
-				I40E_DDP_NAME_SIZE);
+			snprintf(pinfo[j].name, I40E_DDP_NAME_SIZE, "%s",
+				 (const char *)&tlv->data[1]);
 			i += tlv->len;
 			tlv = &tlv[tlv->len];
 		}
-- 
2.5.5

  parent reply	other threads:[~2017-10-24  9:22 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-23 11:24 [dpdk-dev] [PATCH] net/i40e: fix value of num parameter for " Kirill Rybalchenko
2017-10-23 12:57 ` Bruce Richardson
2017-10-23 13:06   ` Rybalchenko, Kirill
2017-10-23 13:30     ` Bruce Richardson
2017-10-24  9:22 ` Kirill Rybalchenko [this message]
2017-10-24  9:50   ` [dpdk-dev] [PATCH] net/i40e: fix unsecure usage of " Bruce Richardson
2017-10-24 18:12     ` Ferruh Yigit

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1508836958-76512-1-git-send-email-kirill.rybalchenko@intel.com \
    --to=kirill.rybalchenko@intel.com \
    --cc=andrey.chilikin@intel.com \
    --cc=beilei.xing@intel.com \
    --cc=dev@dpdk.org \
    --cc=jingjing.wu@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).