From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by dpdk.org (Postfix) with ESMTP id 0334DCF9E for ; Tue, 17 Apr 2018 17:50:20 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 17 Apr 2018 08:50:19 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.48,464,1517904000"; d="scan'208";a="43995993" Received: from irvmail001.ir.intel.com ([163.33.26.43]) by orsmga003.jf.intel.com with ESMTP; 17 Apr 2018 08:50:18 -0700 Received: from sivswdev01.ir.intel.com (sivswdev01.ir.intel.com [10.237.217.45]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id w3HFoHLg032131; Tue, 17 Apr 2018 16:50:17 +0100 Received: from sivswdev01.ir.intel.com (localhost [127.0.0.1]) by sivswdev01.ir.intel.com with ESMTP id w3HFoHAn027030; Tue, 17 Apr 2018 16:50:17 +0100 Received: (from aburakov@localhost) by sivswdev01.ir.intel.com with LOCAL id w3HFoH9w027026; Tue, 17 Apr 2018 16:50:17 +0100 From: Anatoly Burakov To: dev@dpdk.org Cc: Bruce Richardson , thomas@monjalon.net Date: Tue, 17 Apr 2018 16:50:08 +0100 Message-Id: <7cf6d33f079941b648def26111b91c6220d5d8bb.1523977588.git.anatoly.burakov@intel.com> X-Mailer: git-send-email 1.7.0.7 In-Reply-To: References: In-Reply-To: References: Subject: [dpdk-dev] [PATCH 01/10] mem: use strlcpy instead of snprintf X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 17 Apr 2018 15:50:21 -0000 Signed-off-by: Anatoly Burakov --- 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 #include #include +#include #include #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