From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 019294546D for ; Sat, 15 Jun 2024 13:31:27 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E7851402F1; Sat, 15 Jun 2024 13:31:26 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by mails.dpdk.org (Postfix) with ESMTP id 1F2AC40269; Sat, 15 Jun 2024 13:31:23 +0200 (CEST) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 45FBTY7K010109; Sat, 15 Jun 2024 04:31:23 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h= cc:content-transfer-encoding:content-type:date:from:message-id :mime-version:subject:to; s=pfpt0220; bh=9kS3LRuPM6+Jb/lPd6Sv9HJ PSBCNxutOnnQAt3hwb+E=; b=J0hCLIWYouJFsacDdBKtFFEM97C6BE2dspzI+DL cROYQgOcUWPcl6/VJh1STA81XbP5Dmd5biURnWGwub/GE/3wG2o4IJd06RtXbp8W hhvllB3eULwEhsq6hzn7m2Jh4ySKJSI7g98BAlloKJWAnC7WPEpSlp8vqHnnqiff vSt8Di54hx0N8LPtJHshn2+N70NkVIArwr5e3C8VRpiqPTu3LP2F5Viov+A7xFUp hSw3TJmXIzRlMiKYlXK2PI0rhZTHUqEEIa9GQWnOWL/MIHiwiEy5Ixnn0dI5lkgD SpYpYO3TFOqLbkJ+TJzOnb4BQgQdOnLBz8QqngQa1RWS5fA== Received: from dc5-exch05.marvell.com ([199.233.59.128]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3ys8ajr69f-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 15 Jun 2024 04:31:22 -0700 (PDT) Received: from DC5-EXCH05.marvell.com (10.69.176.209) by DC5-EXCH05.marvell.com (10.69.176.209) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Sat, 15 Jun 2024 04:31:22 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH05.marvell.com (10.69.176.209) with Microsoft SMTP Server id 15.2.1544.4 via Frontend Transport; Sat, 15 Jun 2024 04:31:22 -0700 Received: from BG-LT91401.marvell.com (unknown [10.28.168.34]) by maili.marvell.com (Postfix) with ESMTP id 590BB5B692E; Sat, 15 Jun 2024 04:31:20 -0700 (PDT) From: Gowrishankar Muthukrishnan To: , Brian Dooley , "Gowrishankar Muthukrishnan" CC: Anoob Joseph , Subject: [PATCH] examples/fips_validation: fix coverity issues Date: Sat, 15 Jun 2024 17:01:13 +0530 Message-ID: <20240615113118.2137-1-gmuthukrishn@marvell.com> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-GUID: 5t7Mei4ChPX60OlF-iceJUleMpGVDBvF X-Proofpoint-ORIG-GUID: 5t7Mei4ChPX60OlF-iceJUleMpGVDBvF X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-06-15_08,2024-06-14_03,2024-05-17_01 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 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 Fix NULL dereference, out-of-bound, bad bit shift issues reported by coverity scan. Coverity issue: 384440, 384435, 384433, 384429 Fixes: 36128a67c27 ("examples/fips_validation: add asymmetric validation") Cc: stable@dpdk.org Signed-off-by: Gowrishankar Muthukrishnan --- examples/fips_validation/fips_validation_rsa.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/examples/fips_validation/fips_validation_rsa.c b/examples/fips_validation/fips_validation_rsa.c index f675b51051..55f81860a0 100644 --- a/examples/fips_validation/fips_validation_rsa.c +++ b/examples/fips_validation/fips_validation_rsa.c @@ -328,6 +328,9 @@ parse_test_rsa_json_interim_writeback(struct fips_val *val) if (prepare_vec_rsa() < 0) return -1; + if (!vec.rsa.e.val) + return -1; + writeback_hex_str("", info.one_line_text, &vec.rsa.n); obj = json_string(info.one_line_text); json_object_set_new(json_info.json_write_group, "n", obj); @@ -474,7 +477,7 @@ fips_test_randomize_message(struct fips_val *msg, struct fips_val *rand) uint16_t rv_len; if (!msg->val || !rand->val || rand->len > RV_BUF_LEN - || msg->len > FIPS_TEST_JSON_BUF_LEN) + || msg->len > (FIPS_TEST_JSON_BUF_LEN - 1)) return -EINVAL; memset(rv, 0, sizeof(rv)); @@ -503,7 +506,7 @@ fips_test_randomize_message(struct fips_val *msg, struct fips_val *rand) m[i + j] ^= rv[j]; m[i + j] = ((uint8_t *)&rv_bitlen)[0]; - m[i + j + 1] = (((uint8_t *)&rv_bitlen)[1] >> 8) & 0xFF; + m[i + j + 1] = ((uint8_t *)&rv_bitlen)[1]; rte_free(msg->val); msg->len = (rv_bitlen + m_bitlen + 16) / 8; -- 2.25.1