From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from netronome.com (unknown [217.38.71.146]) by dpdk.org (Postfix) with ESMTP id 28CEC1B460 for ; Fri, 15 Feb 2019 11:30:45 +0100 (CET) Received: from netronome.com (localhost [127.0.0.1]) by netronome.com (8.15.2/8.15.2/Debian-10) with ESMTP id x1FAUi62010347; Fri, 15 Feb 2019 10:30:44 GMT Received: (from root@localhost) by netronome.com (8.15.2/8.15.2/Submit) id x1FAUiYr010346; Fri, 15 Feb 2019 10:30:44 GMT From: Alejandro Lucero To: stable@dpdk.org Cc: yskoh@mellanox.com Date: Fri, 15 Feb 2019 10:30:44 +0000 Message-Id: <20190215103044.10301-1-alejandro.lucero@netronome.com> X-Mailer: git-send-email 2.17.1 Subject: [dpdk-stable] [PATH 17.11] net/nfp: fix misuse of strlcpy 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: Fri, 15 Feb 2019 10:30:45 -0000 Current strlcpy function is doing the wrong thing and as a consequence the firmware does not find the symbol requested precluding the right NFP initialization. Using strncpy is safe here since the symbol length can never be longer than the buffer size where the firmware will get the symbol to work with. However, newer compilers do not allow to have the strncpy using the source length as the third parameter, so this patch uses instead a memcpy call with a previous memset for cleaning up the buffer to be used by the firmware. Fixes: a5d659c2d03f ("net/nfp: replace strncpy by strlcpy") Signed-off-by: Alejandro Lucero --- drivers/net/nfp/nfp_nspu.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/net/nfp/nfp_nspu.c b/drivers/net/nfp/nfp_nspu.c index ac5bce3b1..d4abb6c8e 100644 --- a/drivers/net/nfp/nfp_nspu.c +++ b/drivers/net/nfp/nfp_nspu.c @@ -424,7 +424,9 @@ nfp_nspu_set_bar_from_symbl(nspu_desc_t *desc, const char *symbl, if (!sym_buf) return -ENOMEM; - strlcpy(sym_buf, symbl, sizeof(sym_buf)); + memset(sym_buf, 0, desc->buf_size); + memcpy(sym_buf, symbl, strlen(symbl)); + ret = nspu_command(desc, NSP_CMD_GET_SYMBOL, 1, 1, sym_buf, NFP_SYM_DESC_LEN, strlen(symbl)); if (ret) { -- 2.17.1