From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id B2F97A04DB for ; Wed, 2 Dec 2020 15:39:57 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id AC7EAC99C; Wed, 2 Dec 2020 15:39:56 +0100 (CET) Received: from proxy.6wind.com (host.76.145.23.62.rev.coltfrance.com [62.23.145.76]) by dpdk.org (Postfix) with ESMTP id AA2F2C99C for ; Wed, 2 Dec 2020 15:39:55 +0100 (CET) Received: from glumotte.dev.6wind.com. (unknown [10.16.0.195]) by proxy.6wind.com (Postfix) with ESMTP id 92EB749C978; Wed, 2 Dec 2020 15:39:54 +0100 (CET) From: Olivier Matz To: stable@dpdk.org Cc: Fan Zhang Date: Wed, 2 Dec 2020 15:39:47 +0100 Message-Id: <20201202143946.26704-1-olivier.matz@6wind.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-stable] [PATCH 18.11] examples/fips_validation: fix buffer overflow 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: , Errors-To: stable-bounces@dpdk.org Sender: "stable" [ upstream commit 9275af3bd9faa0337b418736bb622704d158fbac ] If the file name is larger than MAX_STRING_SIZE (64), strcpy() will overwrite the content of memory. Replace strcpy() by rte_strscpy(), check its return value, and increase file_name size to 256. Fixes: 3d0fad56b74a ("examples/fips_validation: add crypto FIPS application") Cc: stable@dpdk.org Signed-off-by: Olivier Matz Acked-by: Fan Zhang Conflicts: examples/fips_validation/fips_validation.c examples/fips_validation/fips_validation.h Most of the original commit has been removed, because a part of the issue was introduced by commit efe3a8dbb66e ("examples/fips_validation: support TDES ECB"), and it is not present in this branch. Only the length check on the device name remains. Signed-off-by: Olivier Matz --- examples/fips_validation/fips_validation.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/examples/fips_validation/fips_validation.c b/examples/fips_validation/fips_validation.c index d46f72d9b8..3ea7ffaee7 100644 --- a/examples/fips_validation/fips_validation.c +++ b/examples/fips_validation/fips_validation.c @@ -255,7 +255,11 @@ fips_test_init(const char *req_file_path, const char *rsp_file_path, return -ENOMEM; } - strlcpy(info.device_name, device_name, sizeof(info.device_name)); + if (rte_strscpy(info.device_name, device_name, + sizeof(info.device_name)) < 0) { + RTE_LOG(ERR, USER1, "Device name %s too long\n", device_name); + return -EINVAL; + } if (fips_test_parse_header() < 0) { RTE_LOG(ERR, USER1, "Failed parsing header\n"); -- 2.25.1