From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from out5-smtp.messagingengine.com (out5-smtp.messagingengine.com [66.111.4.29]) by dpdk.org (Postfix) with ESMTP id ED6FE91; Mon, 12 Nov 2018 00:59:08 +0100 (CET) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 4792620CA5; Sun, 11 Nov 2018 18:59:07 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Sun, 11 Nov 2018 18:59:07 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monjalon.net; h= from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; s=mesmtp; bh=COChAmCAiqoxXff49Tzd5ur iPPAGzs13cs77nsGPrtI=; b=apvjvz5GMkhgk2yS1gMsrDue0HnRFD5Iq5W9wq0 6Lu2II67PB6KUQxwBUlOKeEpTeEe+gGqUIcpvQCxJwckelu2qpqTYaE/EjlrpqwJ 3qCXdcZLqrRD2z8gOofvwWTv/vQiHNp7xDR7NjFzfNulkTUUsPtyuXAqstu43/N5 Mqmo= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :message-id:mime-version:subject:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=COChAmCAiqoxXff49 Tzd5uriPPAGzs13cs77nsGPrtI=; b=bzZjwbBwFgcfuLnMU6pDraUVqs/i/aelc X/CJardEbzTWb4nMRfGO4NownGeGdCyY5KdZBxLxU77kCO9IHgfPbnydd8AOwxeC W7puMXa0NYkdNIfhaGD+uNz9m1l8NynN4G8f3CKAJJO1XhjxKFrarMA6nmjyxrSb N+TK/dovJt3aKRbGkGgBK1ExBQlwssrLpKrYn+f+wBSFOZDknWWTn57wr8a+YMTZ jym0LsefGzVaHs4bWDo4brjBl76ZNDbPhqRq6J1G/XPhIxFke1DPdG1ZPnjZOERl uCi1/Rop4Iart0XFZpt9EVyPopIWwmfNSMMduzBJGdU4pw6uIH8/g== X-ME-Sender: X-ME-Proxy: Received: from xps.monjalon.net (184.203.134.77.rev.sfr.net [77.134.203.184]) by mail.messagingengine.com (Postfix) with ESMTPA id 1FAF0102E4; Sun, 11 Nov 2018 18:59:06 -0500 (EST) From: Thomas Monjalon To: gaetan.rivet@6wind.com Cc: dev@dpdk.org, wisamm@mellanox.com, stable@dpdk.org Date: Mon, 12 Nov 2018 00:58:56 +0100 Message-Id: <20181111235856.31429-1-thomas@monjalon.net> X-Mailer: git-send-email 2.19.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-stable] [PATCH] pci: fix parsing of address without function number X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 11 Nov 2018 23:59:09 -0000 If the last part of the PCI address (function number) is missing, the parsing was successful, assuming function 0. The call to strtoul is not returning an error in such a case, so an explicit check is inserted before. This bug has always been there in older parsing macros: - GET_PCIADDR_FIELD - GET_BLACKLIST_FIELD Fixes: af75078fece3 ("first public release") Cc: stable@dpdk.org Reported-by: Wisam Jaddo Signed-off-by: Thomas Monjalon --- lib/librte_pci/rte_pci.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/librte_pci/rte_pci.c b/lib/librte_pci/rte_pci.c index 530738dbd..f400178bb 100644 --- a/lib/librte_pci/rte_pci.c +++ b/lib/librte_pci/rte_pci.c @@ -30,6 +30,10 @@ get_u8_pciaddr_field(const char *in, void *_u8, char dlm) uint8_t *u8 = _u8; char *end; + /* empty string is an error though strtoul() returns 0 */ + if (*in == '\0') + return NULL; + errno = 0; val = strtoul(in, &end, 16); if (errno != 0 || end[0] != dlm || val > UINT8_MAX) { -- 2.19.0