From patchwork Fri Aug 12 11:57:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gowrishankar Muthukrishnan X-Patchwork-Id: 114915 X-Patchwork-Delegate: gakhil@marvell.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 2BCD9A0543; Fri, 12 Aug 2022 13:57:49 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 09E9242C21; Fri, 12 Aug 2022 13:57:43 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by mails.dpdk.org (Postfix) with ESMTP id BCF8B42C21 for ; Fri, 12 Aug 2022 13:57:40 +0200 (CEST) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 27C46TPX027499; Fri, 12 Aug 2022 04:57:39 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=pfpt0220; bh=Xi2rNWU/pqIcjflc6Rul6zHYDbxsB2Z+R+shYSDuLmk=; b=fIpvg29iTHLJPW/SpVVWtOHgVIChmgJqKuytdeTFXV0rNuOgjjm31rmHkvU0lFv8TQR2 HCGXTJkRnn1bMW2cI4ecOQQhKfd34kLok3YTk26e7NXiDKofo8o71eDkwKdu9/lnY0sq C7b0jpdmtYcKz1kRrUFHLGpxWI4l+g+K/jzI0s9TNC69gCwOAm7YYHs33h2asMuz/z68 iDZAIGkVIfoY+GwNcXPqdoIa2IauDXB/40FSjQZla9hi5wVMvxD7WA2R9zhfZoGnC12V ok0UfOh1CygwLjzHobmrlKXPw1QQxEcetRQoCv5R/u/8H109X6JDpGjSK1z1U1XKme1/ yg== Received: from dc5-exch02.marvell.com ([199.233.59.182]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3hwfj0hbqj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Fri, 12 Aug 2022 04:57:39 -0700 Received: from DC5-EXCH01.marvell.com (10.69.176.38) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Fri, 12 Aug 2022 04:57:38 -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; Fri, 12 Aug 2022 04:57:38 -0700 Received: from localhost.localdomain (unknown [10.28.34.38]) by maili.marvell.com (Postfix) with ESMTP id AAFEF5B6934; Fri, 12 Aug 2022 04:57:35 -0700 (PDT) From: Gowrishankar Muthukrishnan To: CC: Anoob Joseph , Fan Zhang , Brian Dooley , Akhil Goyal , , Gowrishankar Muthukrishnan Subject: [PATCH v1 4/5] examples/fips_validation: fix buffer size to parse JSON string Date: Fri, 12 Aug 2022 17:27:19 +0530 Message-ID: <8f51c9f78fa6693d4274a9a4c743fcd0f2f2daf7.1660304194.git.gmuthukrishn@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: qNOr8RBOiDK_qvfpk4I5UWTsT0Q27uO_ X-Proofpoint-GUID: qNOr8RBOiDK_qvfpk4I5UWTsT0Q27uO_ 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-08-12_08,2022-08-11_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 In asym op, while parsing test interim info, existing buffer of size 256 bytes is not sufficient, hence setting it to maximum that a test would need. Fixes: 58cc98801eb ("examples/fips_validation: add JSON parsing") Signed-off-by: Gowrishankar Muthukrishnan --- examples/fips_validation/fips_validation.c | 7 ++++--- examples/fips_validation/fips_validation.h | 7 +++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/examples/fips_validation/fips_validation.c b/examples/fips_validation/fips_validation.c index e755654cd0..be0634c3ac 100644 --- a/examples/fips_validation/fips_validation.c +++ b/examples/fips_validation/fips_validation.c @@ -484,7 +484,7 @@ fips_test_parse_one_json_group(void) json_t *param; if (info.interim_callbacks) { - char json_value[256]; + char json_value[FIPS_TEST_JSON_BUF_LEN]; for (i = 0; info.interim_callbacks[i].key != NULL; i++) { param = json_object_get(json_info.json_test_group, info.interim_callbacks[i].key); @@ -493,11 +493,12 @@ fips_test_parse_one_json_group(void) switch (json_typeof(param)) { case JSON_STRING: - snprintf(json_value, 256, "%s", json_string_value(param)); + snprintf(json_value, sizeof(json_value), "%s", + json_string_value(param)); break; case JSON_INTEGER: - snprintf(json_value, 255, "%"JSON_INTEGER_FORMAT, + snprintf(json_value, sizeof(json_value), "%"JSON_INTEGER_FORMAT, json_integer_value(param)); break; diff --git a/examples/fips_validation/fips_validation.h b/examples/fips_validation/fips_validation.h index 4732341dd3..926fe94563 100644 --- a/examples/fips_validation/fips_validation.h +++ b/examples/fips_validation/fips_validation.h @@ -183,6 +183,13 @@ struct xts_interim_data { }; #ifdef USE_JANSSON +/* + * Maximum length of buffer to hold any json string. + * Esp, in asym op, modulo bits decide char buffer size. + * max = (modulo / 4) + */ +#define FIPS_TEST_JSON_BUF_LEN (4096 / 4) + struct fips_test_json_info { /* Information used for reading from json */ json_t *json_root;