From mboxrd@z Thu Jan 1 00:00:00 1970 From: Thomas Monjalon Subject: [PATCH] eal/linux: use strlcpy in uevent parsing Date: Tue, 17 Apr 2018 13:57:57 +0200 Message-ID: <20180417115757.17633-1-thomas@monjalon.net> Cc: anatoly.burakov@intel.com, bruce.richardson@intel.com, jia.guo@intel.com To: dev@dpdk.org Return-path: Received: from out3-smtp.messagingengine.com (out3-smtp.messagingengine.com [66.111.4.27]) by dpdk.org (Postfix) with ESMTP id AB161A48F for ; Tue, 17 Apr 2018 13:58:04 +0200 (CEST) List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Support of strlcpy has recently been added to DPDK. This replacement has been generated by the coccinelle script: devtools/cocci.sh devtools/cocci/strlcpy.cocci Fixes: 0d0f478d0483 ("eal/linux: add uevent parse and process") Cc: jia.guo@intel.com Signed-off-by: Thomas Monjalon --- lib/librte_eal/linuxapp/eal/eal_dev.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/librte_eal/linuxapp/eal/eal_dev.c b/lib/librte_eal/linuxapp/eal/eal_dev.c index 9478a39a5..d02bba11e 100644 --- a/lib/librte_eal/linuxapp/eal/eal_dev.c +++ b/lib/librte_eal/linuxapp/eal/eal_dev.c @@ -94,15 +94,15 @@ dev_uev_parse(const char *buf, struct rte_dev_event *event, int length) if (!strncmp(buf, "ACTION=", 7)) { buf += 7; i += 7; - snprintf(action, sizeof(action), "%s", buf); + strlcpy(action, buf, sizeof(action)); } else if (!strncmp(buf, "SUBSYSTEM=", 10)) { buf += 10; i += 10; - snprintf(subsystem, sizeof(subsystem), "%s", buf); + strlcpy(subsystem, buf, sizeof(subsystem)); } else if (!strncmp(buf, "PCI_SLOT_NAME=", 14)) { buf += 14; i += 14; - snprintf(pci_slot_name, sizeof(subsystem), "%s", buf); + strlcpy(pci_slot_name, buf, sizeof(subsystem)); event->devname = strdup(pci_slot_name); } for (; i < length; i++) { -- 2.16.2