DPDK patches and discussions
 help / color / mirror / Atom feed
From: Anatoly Burakov <anatoly.burakov@intel.com>
To: dev@dpdk.org
Cc: Bruce Richardson <bruce.richardson@intel.com>, thomas@monjalon.net
Subject: [dpdk-dev] [PATCH 01/10] mem: use strlcpy instead of snprintf
Date: Tue, 17 Apr 2018 16:50:08 +0100	[thread overview]
Message-ID: <7cf6d33f079941b648def26111b91c6220d5d8bb.1523977588.git.anatoly.burakov@intel.com> (raw)
In-Reply-To: <cover.1523977588.git.anatoly.burakov@intel.com>
In-Reply-To: <cover.1523977588.git.anatoly.burakov@intel.com>

Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
---

Notes:
    One other instance of using snprintf is left alone as
    it is expected to be addressed by another patch [1].
    
    [1] http://dpdk.org/dev/patchwork/patch/38301/

 lib/librte_eal/bsdapp/eal/eal_hugepage_info.c | 2 +-
 lib/librte_eal/common/eal_common_memalloc.c   | 5 +++--
 lib/librte_eal/linuxapp/eal/eal_memory.c      | 4 ++--
 3 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/lib/librte_eal/bsdapp/eal/eal_hugepage_info.c b/lib/librte_eal/bsdapp/eal/eal_hugepage_info.c
index 38d143c..836feb6 100644
--- a/lib/librte_eal/bsdapp/eal/eal_hugepage_info.c
+++ b/lib/librte_eal/bsdapp/eal/eal_hugepage_info.c
@@ -96,7 +96,7 @@ eal_hugepage_info_init(void)
 		RTE_LOG(INFO, EAL, "Contigmem driver has %d buffers, each of size %dKB\n",
 				num_buffers, (int)(buffer_size>>10));
 
-	snprintf(hpi->hugedir, sizeof(hpi->hugedir), "%s", CONTIGMEM_DEV);
+	strlcpy(hpi->hugedir, CONTIGMEM_DEV, sizeof(hpi->hugedir));
 	hpi->hugepage_sz = buffer_size;
 	hpi->num_pages[0] = num_buffers;
 	hpi->lock_descriptor = fd;
diff --git a/lib/librte_eal/common/eal_common_memalloc.c b/lib/librte_eal/common/eal_common_memalloc.c
index 49fd53c..e983688 100644
--- a/lib/librte_eal/common/eal_common_memalloc.c
+++ b/lib/librte_eal/common/eal_common_memalloc.c
@@ -10,6 +10,7 @@
 #include <rte_memzone.h>
 #include <rte_memory.h>
 #include <rte_eal_memconfig.h>
+#include <rte_string_fns.h>
 #include <rte_rwlock.h>
 
 #include "eal_private.h"
@@ -179,7 +180,7 @@ eal_memalloc_mem_event_callback_register(const char *name,
 
 	/* callback successfully created and is valid, add it to the list */
 	entry->clb = clb;
-	snprintf(entry->name, RTE_MEM_EVENT_CALLBACK_NAME_LEN, "%s", name);
+	strlcpy(entry->name, name, RTE_MEM_EVENT_CALLBACK_NAME_LEN);
 	TAILQ_INSERT_TAIL(&mem_event_callback_list, entry, next);
 
 	ret = 0;
@@ -284,7 +285,7 @@ eal_memalloc_mem_alloc_validator_register(const char *name,
 	entry->clb = clb;
 	entry->socket_id = socket_id;
 	entry->limit = limit;
-	snprintf(entry->name, RTE_MEM_ALLOC_VALIDATOR_NAME_LEN, "%s", name);
+	strlcpy(entry->name, name, RTE_MEM_ALLOC_VALIDATOR_NAME_LEN);
 	TAILQ_INSERT_TAIL(&mem_alloc_validator_list, entry, next);
 
 	ret = 0;
diff --git a/lib/librte_eal/linuxapp/eal/eal_memory.c b/lib/librte_eal/linuxapp/eal/eal_memory.c
index b7a2e95..391b0de 100644
--- a/lib/librte_eal/linuxapp/eal/eal_memory.c
+++ b/lib/librte_eal/linuxapp/eal/eal_memory.c
@@ -1160,8 +1160,8 @@ calc_num_pages_per_socket(uint64_t * memory,
 	for (socket = 0; socket < RTE_MAX_NUMA_NODES && total_mem != 0; socket++) {
 		/* skips if the memory on specific socket wasn't requested */
 		for (i = 0; i < num_hp_info && memory[socket] != 0; i++){
-			snprintf(hp_used[i].hugedir, sizeof(hp_used[i].hugedir),
-					"%s", hp_info[i].hugedir);
+			strlcpy(hp_used[i].hugedir, hp_info[i].hugedir,
+					sizeof(hp_used[i].hugedir));
 			hp_used[i].num_pages[socket] = RTE_MIN(
 					memory[socket] / hp_info[i].hugepage_sz,
 					hp_info[i].num_pages[socket]);
-- 
2.7.4

  reply	other threads:[~2018-04-17 15:50 UTC|newest]

Thread overview: 65+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-17 15:50 [dpdk-dev] [PATCH 00/10] Coverity fixes for EAL memory Anatoly Burakov
2018-04-17 15:50 ` Anatoly Burakov [this message]
2018-04-17 15:50 ` [dpdk-dev] [PATCH 02/10] mem: fix resource leak Anatoly Burakov
2018-04-17 15:50 ` [dpdk-dev] [PATCH 03/10] mem: fix potential double close Anatoly Burakov
2018-04-17 15:50 ` [dpdk-dev] [PATCH 04/10] mem: fix potential resource leak Anatoly Burakov
2018-04-17 15:50 ` [dpdk-dev] [PATCH 05/10] " Anatoly Burakov
2018-04-17 15:50 ` [dpdk-dev] [PATCH 06/10] mem: fix comparing pointer to value Anatoly Burakov
2018-04-17 15:50 ` [dpdk-dev] [PATCH 07/10] mem: fix potential bad unmap Anatoly Burakov
2018-04-17 15:50 ` [dpdk-dev] [PATCH 08/10] mem: fix statement having no effect Anatoly Burakov
2018-04-17 15:50 ` [dpdk-dev] [PATCH 09/10] mem: fix negative return value Anatoly Burakov
2018-04-17 15:50 ` [dpdk-dev] [PATCH 10/10] mem: fix possible use-after-free Anatoly Burakov
2018-04-17 15:56 ` [dpdk-dev] [PATCH 00/10] Coverity fixes for EAL memory Thomas Monjalon
2018-04-17 16:09   ` Burakov, Anatoly
2018-04-17 18:59     ` Thomas Monjalon
2018-04-18 10:37 ` [dpdk-dev] [PATCH v2 " Anatoly Burakov
2018-04-18 10:37 ` [dpdk-dev] [PATCH v2 01/10] mem: use strlcpy instead of snprintf Anatoly Burakov
2018-04-18 10:37 ` [dpdk-dev] [PATCH v2 02/10] mem: fix resource leak Anatoly Burakov
2018-04-18 10:37 ` [dpdk-dev] [PATCH v2 03/10] mem: fix potential double close Anatoly Burakov
2018-04-18 10:37 ` [dpdk-dev] [PATCH v2 04/10] mem: fix potential resource leak Anatoly Burakov
2018-04-18 10:37 ` [dpdk-dev] [PATCH v2 05/10] " Anatoly Burakov
2018-04-18 10:37 ` [dpdk-dev] [PATCH v2 06/10] mem: fix comparing pointer to value Anatoly Burakov
2018-04-18 10:37 ` [dpdk-dev] [PATCH v2 07/10] mem: fix potential bad unmap Anatoly Burakov
2018-04-18 10:37 ` [dpdk-dev] [PATCH v2 08/10] mem: fix statement having no effect Anatoly Burakov
2018-04-18 10:37 ` [dpdk-dev] [PATCH v2 09/10] mem: fix negative return value Anatoly Burakov
2018-04-18 10:37 ` [dpdk-dev] [PATCH v2 10/10] mem: fix possible use-after-free Anatoly Burakov
2018-04-25  9:56 ` [dpdk-dev] [PATCH v3 0/9] Coverity fixes for EAL memory Anatoly Burakov
2018-04-27 17:07   ` [dpdk-dev] [PATCH v4 " Anatoly Burakov
2018-04-27 21:25     ` Thomas Monjalon
2018-04-27 17:07   ` [dpdk-dev] [PATCH v4 1/9] mem: use strlcpy instead of snprintf Anatoly Burakov
2018-04-27 17:07   ` [dpdk-dev] [PATCH v4 2/9] mem: fix resource leak Anatoly Burakov
2018-04-27 17:07   ` [dpdk-dev] [PATCH v4 3/9] mem: fix potential double close Anatoly Burakov
2018-04-30  9:00     ` Bruce Richardson
2018-04-27 17:07   ` [dpdk-dev] [PATCH v4 4/9] mem: fix potential resource leak Anatoly Burakov
2018-04-27 17:07   ` [dpdk-dev] [PATCH v4 5/9] " Anatoly Burakov
2018-04-27 17:07   ` [dpdk-dev] [PATCH v4 6/9] mem: fix comparing pointer to value Anatoly Burakov
2018-04-27 17:07   ` [dpdk-dev] [PATCH v4 7/9] mem: fix potential bad unmap Anatoly Burakov
2018-04-27 17:07   ` [dpdk-dev] [PATCH v4 8/9] mem: fix statement having no effect Anatoly Burakov
2018-04-27 17:07   ` [dpdk-dev] [PATCH v4 9/9] mem: fix possible use-after-free Anatoly Burakov
2018-04-25  9:56 ` [dpdk-dev] [PATCH v3 1/9] mem: use strlcpy instead of snprintf Anatoly Burakov
2018-04-27 15:08   ` Bruce Richardson
2018-04-25  9:56 ` [dpdk-dev] [PATCH v3 2/9] mem: fix resource leak Anatoly Burakov
2018-04-27 15:13   ` Bruce Richardson
2018-04-25  9:56 ` [dpdk-dev] [PATCH v3 3/9] mem: fix potential double close Anatoly Burakov
2018-04-27 15:15   ` Bruce Richardson
2018-04-27 16:56     ` Burakov, Anatoly
2018-04-25  9:56 ` [dpdk-dev] [PATCH v3 4/9] mem: fix potential resource leak Anatoly Burakov
2018-04-27 15:18   ` Bruce Richardson
2018-04-27 15:28     ` Burakov, Anatoly
2018-04-27 15:39     ` Burakov, Anatoly
2018-04-27 15:48       ` Bruce Richardson
2018-04-25  9:56 ` [dpdk-dev] [PATCH v3 5/9] " Anatoly Burakov
2018-04-27 15:21   ` Bruce Richardson
2018-04-27 15:49     ` Burakov, Anatoly
2018-04-27 15:52       ` Bruce Richardson
2018-04-27 15:55     ` Burakov, Anatoly
2018-04-27 16:27       ` Bruce Richardson
2018-04-27 16:42         ` Burakov, Anatoly
2018-04-25  9:56 ` [dpdk-dev] [PATCH v3 6/9] mem: fix comparing pointer to value Anatoly Burakov
2018-04-27 15:22   ` Bruce Richardson
2018-04-25  9:56 ` [dpdk-dev] [PATCH v3 7/9] mem: fix potential bad unmap Anatoly Burakov
2018-04-27 15:37   ` Bruce Richardson
2018-04-25  9:56 ` [dpdk-dev] [PATCH v3 8/9] mem: fix statement having no effect Anatoly Burakov
2018-04-27 15:39   ` Bruce Richardson
2018-04-25  9:56 ` [dpdk-dev] [PATCH v3 9/9] mem: fix possible use-after-free Anatoly Burakov
2018-04-27 15:45   ` 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=7cf6d33f079941b648def26111b91c6220d5d8bb.1523977588.git.anatoly.burakov@intel.com \
    --to=anatoly.burakov@intel.com \
    --cc=bruce.richardson@intel.com \
    --cc=dev@dpdk.org \
    --cc=thomas@monjalon.net \
    /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).