patches for DPDK stable branches
 help / color / mirror / Atom feed
From: "John W. Linville" <linville@tuxdriver.com>
To: dev@dpdk.org
Cc: dpdk stable <stable@dpdk.org>
Subject: [dpdk-stable] [PATCH v2 1/4] net/ena: improve safety of string handling in ena_config_host_info
Date: Thu, 29 Sep 2016 13:39:33 -0400	[thread overview]
Message-ID: <1475170776-10130-2-git-send-email-linville@tuxdriver.com> (raw)
In-Reply-To: <1475170776-10130-1-git-send-email-linville@tuxdriver.com>

Use sizeof dest rather than sizeof src for limiting copy length,
and replace strncpy with snprintf to ensure NULL termination.

Coverity issue: 127795
Fixes: 372c1af5ed8f ("net/ena: add dedicated memory area for extra device info")

Signed-off-by: John W. Linville <linville@tuxdriver.com>
---
v2: fix-up changelog entries based-on comments from Ferruh Yigit

 drivers/net/ena/ena_ethdev.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ena/ena_ethdev.c b/drivers/net/ena/ena_ethdev.c
index d106f5f39dce..649cb17d4a06 100644
--- a/drivers/net/ena/ena_ethdev.c
+++ b/drivers/net/ena/ena_ethdev.c
@@ -342,11 +342,13 @@ static void ena_config_host_info(struct ena_com_dev *ena_dev)
 
 	host_info->os_type = ENA_ADMIN_OS_DPDK;
 	host_info->kernel_ver = RTE_VERSION;
-	strncpy((char *)host_info->kernel_ver_str, rte_version(),
-		strlen(rte_version()));
+	snprintf((char *)host_info->kernel_ver_str,
+		 sizeof(host_info->kernel_ver_str),
+		 "%s", rte_version());
 	host_info->os_dist = RTE_VERSION;
-	strncpy((char *)host_info->os_dist_str, rte_version(),
-		strlen(rte_version()));
+	snprintf((char *)host_info->os_dist_str,
+		 sizeof(host_info->os_dist_str),
+		 "%s", rte_version());
 	host_info->driver_version =
 		(DRV_MODULE_VER_MAJOR) |
 		(DRV_MODULE_VER_MINOR << ENA_ADMIN_HOST_INFO_MINOR_SHIFT) |
-- 
2.7.4

  reply	other threads:[~2016-09-29 17:45 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1475090404-20707-1-git-send-email-linville@tuxdriver.com>
     [not found] ` <1475090404-20707-4-git-send-email-linville@tuxdriver.com>
2016-09-29  8:15   ` [dpdk-stable] [dpdk-dev] [PATCH 3/4] i40e_vsi_release: do not use vsi until after NULL check Ferruh Yigit
2016-09-29 17:39 ` [dpdk-stable] [PATCH v2 0/4] random fixes for bugs identified by Coverity John W. Linville
2016-09-29 17:39   ` John W. Linville [this message]
2016-10-12 16:24     ` [dpdk-stable] [PATCH v2 1/4] net/ena: improve safety of string handling in ena_config_host_info Ferruh Yigit
2016-09-29 17:39   ` [dpdk-stable] [PATCH v2 2/4] net/bnxt: ensure entry_length is unsigned in bnxt_alloc_vnic_attributes John W. Linville
2016-09-29 19:06     ` [dpdk-stable] [dpdk-dev] " Ajit Khaparde
2016-09-29 17:39   ` [dpdk-stable] [PATCH v2 3/4] net/i40e: do not use vsi until after NULL check in i40e_vsi_release John W. Linville
2016-09-29 17:39   ` [dpdk-stable] [PATCH v2 4/4] net/bnxt: add ULL suffix to constant 1 for bit shift in bnxt_mac_addr_remove_op John W. Linville
2016-10-10 18:41     ` [dpdk-stable] [dpdk-dev] " Ajit Khaparde
2016-10-13  9:31   ` [dpdk-stable] [dpdk-dev] [PATCH v2 0/4] random fixes for bugs identified by Coverity Bruce Richardson

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=1475170776-10130-2-git-send-email-linville@tuxdriver.com \
    --to=linville@tuxdriver.com \
    --cc=dev@dpdk.org \
    --cc=stable@dpdk.org \
    /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).