From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from out3-smtp.messagingengine.com (out3-smtp.messagingengine.com [66.111.4.27]) by dpdk.org (Postfix) with ESMTP id 421C35F0D for ; Tue, 17 Apr 2018 14:23:33 +0200 (CEST) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id B64892101D; Tue, 17 Apr 2018 08:23:32 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Tue, 17 Apr 2018 08:23:32 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monjalon.net; h= cc:date:from:in-reply-to:message-id:references:subject:to :x-me-sender:x-me-sender:x-sasl-enc; s=mesmtp; bh=ETlVWHjtJSbUVw TT5WcKP2FKlYawuFgwofL/s0EBasI=; b=X+XLpV1whTQtyxhvahIdD5jnB0J6gm lVrmf5P87km+YEHFv/IiyHHuCayBGIJ6nDdqPfCP33UrYeUndOyDz3zg81bG9CCi vmpaNz8RKNTwvsmVdUiANo1LImOo2fE9kQmCZCuDjZavEfnUzpGN2w+7I3R8hUl4 2qBVh3WiG0PRo= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:date:from:in-reply-to:message-id :references:subject:to:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; bh=ETlVWHjtJSbUVwTT5WcKP2FKlYawuFgwofL/s0EBasI=; b=I8/K2I2X cSDqK61g5sltneikMbHAtJ1F5kwSDCBe3hDShAzQRO6QXH+59WzZDZUnDqarpAs+ YzEqwOeCTM0ziPT0I1XqIyBQ+3CibQmjk0S7XSn6N5/AM0MvQHPXJf0PX93erql6 ZwjqMhA4JjefYVYhbDORhDBbUBcqfsc7ysnSbqYO6MgOjJ7NWgSlcW/cjQWnHliN eNZz8OIza0c6D2EuESfLJyXxLWW6x19/Knfh0qxhG6LxtUicAqTCkACqB/V2qKjV NOISPYVO0SxsBOkaxiFsJnoo+8rTzAqcFbJ/QFbfeIYDVddstVrIJ1Jr/7KLaQcN HsMKicvMKEQ8LQ== X-ME-Sender: Received: from xps.monjalon.net (184.203.134.77.rev.sfr.net [77.134.203.184]) by mail.messagingengine.com (Postfix) with ESMTPA id EA746E4120; Tue, 17 Apr 2018 08:23:31 -0400 (EDT) From: Thomas Monjalon To: dev@dpdk.org Cc: anatoly.burakov@intel.com, bruce.richardson@intel.com Date: Tue, 17 Apr 2018 14:23:29 +0200 Message-Id: <20180417122329.19492-1-thomas@monjalon.net> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180417115757.17633-1-thomas@monjalon.net> References: <20180417115757.17633-1-thomas@monjalon.net> Subject: [dpdk-dev] [PATCH v2] eal/linux: use strlcpy in uevent parsing 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 12:23:33 -0000 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") Signed-off-by: Thomas Monjalon --- v2: add missing include --- lib/librte_eal/linuxapp/eal/eal_dev.c | 7 ++++--- 1 file changed, 4 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..1cf6aebff 100644 --- a/lib/librte_eal/linuxapp/eal/eal_dev.c +++ b/lib/librte_eal/linuxapp/eal/eal_dev.c @@ -7,6 +7,7 @@ #include #include +#include #include #include #include @@ -94,15 +95,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