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 06562A0093; Sat, 2 Jul 2022 16:51:20 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 935C140E50; Sat, 2 Jul 2022 16:51:19 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id ECA6340E03 for ; Sat, 2 Jul 2022 16:51:17 +0200 (CEST) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 262Ds0bm009110; Sat, 2 Jul 2022 07:51:17 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : mime-version : content-transfer-encoding : content-type; s=pfpt0220; bh=tMNmvGv7hl/nS68yLXnVn56Mh0llzKIx4drSLVxglUg=; b=iNIfLx1wZRY2gsJRhOMdBhwWKqeBjgr4x1bjJWzKXQVLbT7xsoeo/0LGCNLgm9thrC06 Twiy8djNFWX1H0cv3zHtCKWWbOxl2/FIyxX6GtiWSslrUX2dj5psr36KMD2f0sZ4clpd u02lp2I89xCwxdBZOYXDz4+vXLfGY3km5bpcKrvH17lfKe1Y1FI3QzFrmWQ+wrTz2GMp d5sT1AZAzvisJ0PaQFwTXyZmLY5lwA7TrsFHkwXWgfJLbFD8zQcZgxxfDL3+TfDaniqC EZg5GoJqpj1fsb7BkSzqs1SriFYODHjLC3JhAinPOrYQH8GISiT28iFqi5hQH3KeFGxI Iw== Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3h2nhng8wd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Sat, 02 Jul 2022 07:51:17 -0700 Received: from DC5-EXCH01.marvell.com (10.69.176.38) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Sat, 2 Jul 2022 07:51:15 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Sat, 2 Jul 2022 07:51:15 -0700 Received: from localhost.localdomain (unknown [10.28.34.38]) by maili.marvell.com (Postfix) with ESMTP id 751023F7092; Sat, 2 Jul 2022 07:51:12 -0700 (PDT) From: Gowrishankar Muthukrishnan To: CC: Akhil Goyal , Fan Zhang , Brian Dooley , Anoob Joseph , Archana Muniganti , Jerin Jacob , Gowrishankar Muthukrishnan Subject: [PATCH v1] examples/fips_validation: fix memory leak in sha test Date: Sat, 2 Jul 2022 20:21:08 +0530 Message-ID: <2acc661bc1b574166e599957c805d70eee0d3a42.1656773321.git.gmuthukrishn@marvell.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-ORIG-GUID: W1SE7X0uUUyJqGnnHJNuB401gj_t4fkO X-Proofpoint-GUID: W1SE7X0uUUyJqGnnHJNuB401gj_t4fkO X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.883,Hydra:6.0.517,FMLib:17.11.122.1 definitions=2022-07-02_11,2022-06-28_01,2022-06-22_01 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org There is wrong size used for allocation of digest buffer which in some cases cause memory corruption. Also, fixed places where memory leak is observed. Fixes: 93d797d94f1 ("examples/fips_validation: add parsing for sha") Signed-off-by: Gowrishankar Muthukrishnan --- examples/fips_validation/fips_validation_sha.c | 10 ++++++++-- examples/fips_validation/main.c | 1 + 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/examples/fips_validation/fips_validation_sha.c b/examples/fips_validation/fips_validation_sha.c index a2928618d7..538cb6647a 100644 --- a/examples/fips_validation/fips_validation_sha.c +++ b/examples/fips_validation/fips_validation_sha.c @@ -229,13 +229,19 @@ parse_test_sha_json_algorithm(void) for (i = 0; i < RTE_DIM(phsc); i++) { if (info.interim_info.sha_data.algo == phsc[i].algo) { vec.cipher_auth.digest.len = atoi(phsc[i].str); - vec.cipher_auth.digest.val = calloc(0, vec.cipher_auth.digest.len * 8); + if (vec.cipher_auth.digest.val) + free(vec.cipher_auth.digest.val); + + vec.cipher_auth.digest.val = calloc(1, vec.cipher_auth.digest.len); break; } } - if (i == RTE_DIM(phsc)) + if (i == RTE_DIM(phsc)) { + free(vec.cipher_auth.digest.val); + vec.cipher_auth.digest.val = NULL; return -1; + } return 0; } diff --git a/examples/fips_validation/main.c b/examples/fips_validation/main.c index 6d52048b5c..8bd5a66889 100644 --- a/examples/fips_validation/main.c +++ b/examples/fips_validation/main.c @@ -2099,6 +2099,7 @@ fips_test_one_json_file(void) json_info.json_vector_set = json_array_get(json_info.json_root, vector_set_idx); fips_test_one_vector_set(); json_array_append_new(json_info.json_write_root, json_info.json_write_set); + json_incref(json_info.json_write_set); } json_dumpf(json_info.json_write_root, info.fp_wr, JSON_INDENT(4)); -- 2.25.1