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 4F72345501 for ; Wed, 26 Jun 2024 12:48:28 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4543942ED2; Wed, 26 Jun 2024 12:48:28 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by mails.dpdk.org (Postfix) with ESMTP id CC20C40B95; Wed, 26 Jun 2024 12:26:35 +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 45Q9jkca020753; Wed, 26 Jun 2024 03:26:34 -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=DbBKbDca9y1sbMtO2dvaoBQ 7OHgEOY34QOIGruSmXss=; b=lBZb3K95JCH8/aPyhy5eFb+VJr5YDv8S76gyFYN JCISCMKwwxVtDAgvh2xlnXptswSQCwNJQIH5JT5w8Hx6Bd0mIAedVxnTUV7CACLr h41XJEV1uQdYsLRT1pAaoau1vYYuebipuyBbbJ217vnmjzyxNhVj5bo3icyDWdRB he93f66epREuoQAhR5uA+xLPDeamaPu3ZUqaPkusv4pKxiiWiE2LoV4baUtCIa/g YVU+BubifKL/fsYwoud/Ce3RfJrOVueeIKC/8QEFSAnSeVzUt+S454oCJuDMhItE Tg+Exu3uionlqWCY1re0MqSs5VQ54F2PfL9u1L0KVTb7cTg== Received: from dc6wp-exch02.marvell.com ([4.21.29.225]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 400ftng99y-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 26 Jun 2024 03:26:34 -0700 (PDT) Received: from DC6WP-EXCH02.marvell.com (10.76.176.209) by DC6WP-EXCH02.marvell.com (10.76.176.209) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Wed, 26 Jun 2024 03:26:32 -0700 Received: from maili.marvell.com (10.69.176.80) by DC6WP-EXCH02.marvell.com (10.76.176.209) with Microsoft SMTP Server id 15.2.1544.4 via Frontend Transport; Wed, 26 Jun 2024 03:26:32 -0700 Received: from BG-LT91401.marvell.com (BG-LT91401.marvell.com [10.28.168.34]) by maili.marvell.com (Postfix) with ESMTP id 303993F707B; Wed, 26 Jun 2024 03:26:29 -0700 (PDT) From: Gowrishankar Muthukrishnan To: , Brian Dooley , "Gowrishankar Muthukrishnan" CC: Anoob Joseph , Subject: [PATCH v2] examples/fips_validation: fix coverity issues Date: Wed, 26 Jun 2024 15:56:23 +0530 Message-ID: <20240626102626.1934-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-ORIG-GUID: JqLTz2sVSYKCNdxx-GQxynkzVCzHxHNw X-Proofpoint-GUID: JqLTz2sVSYKCNdxx-GQxynkzVCzHxHNw 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-26_04,2024-06-25_01,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 Acked-by: Brian Dooley --- v2: - no changes -- 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