From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id C53B674003A for ; Thu, 9 Nov 2023 15:10:45 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=t3sfoRp3B7iRFIpxD99g0II8farxkXEve0GARk7lMKE=; c=relaxed/simple; d=groups.io; h=ARC-Seal:ARC-Message-Signature:ARC-Authentication-Results:From:To:CC:Subject:Thread-Topic:Thread-Index:Date:Message-ID:References:In-Reply-To:Accept-Language:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Language:Content-Type:Content-Transfer-Encoding; s=20140610; t=1699542644; v=1; b=MwpMjisBOALTuGEYvvNPuL9d00lDKJOWV9WOBuyjF8+gx3Cj1bJMllot6jZuCgD9T+GJk4mZ I/+T7BRnS1WAt1b+yAl9/bsb+lt1f9pOiJy5Qqw6vh6ohS92jiHQO44WIqOAol8UZyjZJ0VWLEp r9e/TBwP40oP9oOUsKqqh2gg= X-Received: by 127.0.0.2 with SMTP id tidIYY7687511xMWn5rHNUv6; Thu, 09 Nov 2023 07:10:44 -0800 X-Received: from NAM04-DM6-obe.outbound.protection.outlook.com (NAM04-DM6-obe.outbound.protection.outlook.com [40.107.102.83]) by mx.groups.io with SMTP id smtpd.web10.123759.1699542642736221141 for ; Thu, 09 Nov 2023 07:10:43 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=g7lD9h/eAcuValjeXsjD8qkh1s6J9NqK49fFdWwxiEAd8pAgM3S0al4uYCeGlpIy0bLEl3l8mMqaXrGaa7Pev3Ps0se2UL0O+gOTeTF3KxqLMTrOxroU7MCXHQlybQb6To9v1qqS3LJvchBU9VUpTGdkMDBukFLZufaHk3RnEl90QUQX8N+Jsfs35M8WhC3rISMu0yK0e2ipGF7VUl1/Mv41jBw+dsDel2LzjXQs4jbMEnYrMExnDxQeTEx8QYSenCUxHAwhXBoFDrTCD+F9LXJsQbW0rQ4bv6kxS0A3qGECxZQmvAfUazuC/W1jxaGk+sHWZ9b98lGcfW+3msVgKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=gZ2ki2wF7DKd0cJTIG93YrCgqduGvP28weSOkGOANRo=; b=XBVT18gXQ6/MlTrC9lItp6k4iO/QP+cCnQdRSR7nU93VGW/0+WnvSTU6OlZ2nJtC85rnSLkzRrQXf5MdWhwVOAm+GJispLIRCntTDND2y+NKz2AFf4RNpedFGTOSxJ3RW33g1UhLarRwoS+3VXIWh9mmQao4g3f1FZowFiCH49Gogo5Jx6EnBRH83jkkaf9/mbaQ1/ZDEYUpBJQPyD0zRvaBrjDxFgO32Vn24pj1rfZld0FbE34WchiZ8ukD6CZJuOtzR9CPDA+YJtPZY+SmFLS92/sCR1qZlPT+2d90o7m9osOzCx/GODoeUoTMEJb2Uhb+lu+pIq36WORjcp4JtA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=ami.com; dmarc=pass action=none header.from=ami.com; dkim=pass header.d=ami.com; arc=none X-Received: from BLAPR10MB5185.namprd10.prod.outlook.com (2603:10b6:208:328::16) by PH7PR10MB7719.namprd10.prod.outlook.com (2603:10b6:510:30c::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6954.29; Thu, 9 Nov 2023 15:10:38 +0000 X-Received: from BLAPR10MB5185.namprd10.prod.outlook.com ([fe80::9dc0:d4e1:1d40:3e33]) by BLAPR10MB5185.namprd10.prod.outlook.com ([fe80::9dc0:d4e1:1d40:3e33%4]) with mapi id 15.20.6977.019; Thu, 9 Nov 2023 15:10:38 +0000 From: "Igor Kulchytskyy via groups.io" To: Nickle Wang , "devel@edk2.groups.io" CC: Abner Chang , Nick Ramirez Subject: Re: [edk2-devel] [edk2-redfish-client][PATCH] RedfishClientPkg/RedfishFeatureUtilityLib: validate string array Thread-Topic: [EXTERNAL] [edk2-redfish-client][PATCH] RedfishClientPkg/RedfishFeatureUtilityLib: validate string array Thread-Index: AQHaEhSpvi0zb+dV90OmOborwEIwN7ByAcpA Date: Thu, 9 Nov 2023 15:10:38 +0000 Message-ID: References: <20231108072433.90-1-nicklew@nvidia.com> In-Reply-To: <20231108072433.90-1-nicklew@nvidia.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-publictraffictype: Email x-ms-traffictypediagnostic: BLAPR10MB5185:EE_|PH7PR10MB7719:EE_ x-ms-office365-filtering-correlation-id: 7b1a075a-f8cc-467c-bc72-08dbe136080c x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam-message-info: dfU8j0WhxJHTbe2WbYqXCr+4xnChYKw2wxcfXa/lHoocN9+CbXku80CFd0n4bz60xZFJrOBodVJkxDrOT1oUsmPPOV0ECk3s+0fhQVDV2dxLVJAFsEQeRfVcjtPMkWelEJq/yC9U4c4cUmaOdmEUWl5H07LiSnMXGuIN3zufJ7HgY3DnoewO5D/IOVVmuZe3Ko8nh1m5ZYbapIbgbY70ZWiDYxBvP1VprBYB7UPhuhYx+XFn+H3fsb/TCra8PHjo/I09ssGBrTVLaJZVmra4PSJUBedvcUbPPd/PsWMY9dSiqDfiEwWQSG2ZFCVxN1i2GtUuZqQeozinJfTf5sjdfCNQrCfb/MNEINJ2rGX40+zkGtS7zhgiZKKOlE8gndOhFezYjaxfiZ5bSToNZ9PIMrXYAlKMkscYtROMAu165iSFCfJdrMbdbWB5MYmGwpcSGaXSY27Ao/zuailPhcuSD/Zd0v0kWFN4ha+8ZRne9OmhkC7EROW9XDYCLz5eLDEOThNoRyE62VjSlzKm1a/Lbu8ShO/8YOa6N1eWSwPf9QtL+JG+2bgRAuILlLMDZJcDyW1Tb6CwjPIhyxearVrO45SrNjlOjKmHzUO9vblhNfRmE6x33Ggjl7ebOad4ME4vlF39GfWwSxdMBkkfLASLSQ8SCLUY5NT2IKHKC5oQ++Y= x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?HeKXuUNu2AT9UQkQND5iapEtYwn6m15pkYrP3XHh/fnWp7+o9eoxICUKP60c?= =?us-ascii?Q?wtjMBsYwyUVsocI2P+HQfIy+JRw6fY3hZszyRuycX53O/LYCCbMEHFMs/MS7?= =?us-ascii?Q?lnS/3HY+ZC96Z93IFCvYe5v46FShMaC3R6V0q1rRSNYH94wOOiUOY0+nRMo6?= =?us-ascii?Q?QFKu6PWtxICE9dWHH/huQHILXrE8xaLn9MVSGGM+rdwf6WboZgqZ1qt0ZZ+i?= =?us-ascii?Q?VvUqTKh+dRBynimczti6fAkk850bjhAfvEFEp9iPsr2FlnyncTsnMPvv/MPs?= =?us-ascii?Q?lyErYU9VMxlXLKNqAIu6wws5qIpP3LSSG5U0SCrnxidBAv/DIcoqDbPHEhCL?= =?us-ascii?Q?ZcZDh3P+qQHiX65afxz+bnAJ5MMtwXFghwO4ZWDFxv3s6XpsPbiTklRhgPzG?= =?us-ascii?Q?fHJoWsFZOo5gB0VJLR/tZyQWXdlamRSJSmRQlziLotzlgunEds5Tq/1gCe/j?= =?us-ascii?Q?aQX+N0pXXo57Fui2J/WTEb/0XVyKK7n7qZN2Y2CHZqZD+3zgZLkdIrph/XaA?= =?us-ascii?Q?MMj5jNOG+l4hBOsTSE01m2+RFJBJNvOLlOhpLzLoxZV700WFLhVDzAXxh/F6?= =?us-ascii?Q?ERy0wU/sw/hlq1NLwWYkfX6K2BYQ7PBxnfiQ2sdbVWrQbbXFJ8eeOaTGU+kT?= =?us-ascii?Q?6z9X+VSW6VwwcjUrj9L18fky0DZ80leWiKpa7iUvzDzeGQuRqeVNg43EQZpv?= =?us-ascii?Q?1Vtxtb1RDs1yJqf+Jlv3gmKv9+nmKCcM6f3bGvW9rPIDyQ2oAF3loLOrWkpf?= =?us-ascii?Q?P1uyFEvP6Gyil0nBs/YoCM8+6vBfh7mvdExkpSaC6zvO1yc+pkju/ZnNoJRq?= =?us-ascii?Q?ifUFkt016rAawUDikGCxCHVwhYlbOBvOONJfPT8PYb5PK/eGP/OUAPlNQw/q?= =?us-ascii?Q?9GQauRC64iGPxnPwNVfEZXlZwUVm1XF3QZ/uQtRt/w7t6b/4SPOzKyAllg81?= =?us-ascii?Q?WNsGeBoZsBklTwF0pLej3BI3p4iA1uJgTx+/8+ob5i+qSe4ForGFYal6kLau?= =?us-ascii?Q?n4rtHzXBtITFu7Ur6xT04XLAwq8q/hXCh2zWXE/3iE6xrZu7eOLwEMTHmq0Z?= =?us-ascii?Q?S+WeBdxdafolNPEZW6LZUUBMEEEwBVB4tlwnD8AkFInMynNZ9TNe8slf3awb?= =?us-ascii?Q?aH8bkIuXRt22KCBOzE9xWcGlC8QnoixiBaqgnAjGdAccgtFNPT8DC6FDhxTj?= =?us-ascii?Q?aZm5yOGAMPsMUzN2J/fixgR0ICWqcym6EsRuZ2MBcXMsQq/dviHM7sAxjAdV?= =?us-ascii?Q?FWpsHi26JdDPCDvex9ayKylW4vyxz32chBUNDKEVFxBxE9LooB2gnxbooD0A?= =?us-ascii?Q?dtL8n9aGV74UlRfJPeZc97KeNjr9mFd+Lt57vA2BD29aLzFqgLat2MxpQn8e?= =?us-ascii?Q?Y51Xszwn8Mwqn57lNWTr2QAY5GvydB3BoZVJm0dWEE/IAhkIBa1CCc0Qs70+?= =?us-ascii?Q?+cHnzkBDVgFZwSDS80fwPkVky9tbkUAYhfWvKgZX8ME9Bu2j/gwwMaSfzJu1?= =?us-ascii?Q?DfX72o26LsLQEdbqv0SXoqo+raInvESFAo0Y0v2LbCyqmD1tQVAnYRpkW735?= =?us-ascii?Q?IiOkhlIqOEIKfgzs/fY=3D?= MIME-Version: 1.0 X-OriginatorOrg: ami.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: BLAPR10MB5185.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7b1a075a-f8cc-467c-bc72-08dbe136080c X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Nov 2023 15:10:38.2186 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 27e97857-e15f-486c-b58e-86c2b3040f93 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: MMXf9lF2V5U8haHbU8E8ZYd3klFrfEo+OHuc0xM8oDZNxA6eHZB8jgsIlkHbALeU X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR10MB7719 Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,igork@ami.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: wIN0fFjB3FnHBHXElPkHRZ8hx7686176AA= Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=MwpMjisB; dmarc=none; spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io; arc=reject ("signature check failed: fail, {[1] = sig:microsoft.com:reject}") Hi Nickle, I noticed one typo. See below the text. And I have a question regarding newly introduced ValidateRedfishStringArray= Values function. You use that function to check if value in Redfish string array can be foun= d in HII configuration string array. And you still call CompareRedfishStringArrayValues function. Both iterate t= hrough ArrayHead and RedfishValue.Value.StringArray. Maybe their functionality can be combined in ValidateRedfishStringArrayValu= es? Some additional an out parameter from that function can indicate If the= re is no change in array. What do you think? Thank you, Igor -----Original Message----- From: Nickle Wang Sent: Wednesday, November 8, 2023 2:25 AM To: devel@edk2.groups.io Cc: Abner Chang ; Igor Kulchytskyy ; Ni= ck Ramirez Subject: [EXTERNAL] [edk2-redfish-client][PATCH] RedfishClientPkg/RedfishFe= atureUtilityLib: validate string array **CAUTION: The e-mail below is from an external source. Please exercise cau= tion before opening attachments, clicking links, or following guidance.** - Add function to validate Redfish request for string array type. There is case that user request invalid string array and feature driver can not find corresponding HII option. - Fix typo. Signed-off-by: Nickle Wang Cc: Abner Chang Cc: Igor Kulchytskyy Cc: Nick Ramirez --- .../Library/RedfishFeatureUtilityLib.h | 56 +++++-- .../RedfishFeatureUtilityLib.c | 156 +++++++++++++----- 2 files changed, 154 insertions(+), 58 deletions(-) diff --git a/RedfishClientPkg/Include/Library/RedfishFeatureUtilityLib.h b/= RedfishClientPkg/Include/Library/RedfishFeatureUtilityLib.h index e2f728b2..440c4b68 100644 --- a/RedfishClientPkg/Include/Library/RedfishFeatureUtilityLib.h +++ b/RedfishClientPkg/Include/Library/RedfishFeatureUtilityLib.h @@ -22,7 +22,7 @@ Read redfish resource by given resource URI. - @param[in] Service Redfish srvice instacne to make query. + @param[in] Service Redfish service instance to make query. @param[in] ResourceUri Target resource URI. @param[out] Response HTTP response from redfish service. @@ -47,7 +47,7 @@ GetResourceByUri ( @param[out] ArraySignatureClose String to the close of array signa= ture. @retval EFI_SUCCESS Index is found. - @retval EFI_NOT_FOUND The non-array configure language stri= ng is retured. + @retval EFI_NOT_FOUND The non-array configure language stri= ng is returned. @retval EFI_INVALID_PARAMETER The format of input ConfigureLang is = wrong. @retval Others Errors occur. @@ -118,10 +118,10 @@ GetNumberOfRedpathNodes ( @param[in] NodeString The node string to parse. @param[in] Index Index of the node. - @param[out] EndOfNodePtr Pointer to receive the poitner to + @param[out] EndOfNodePtr Pointer to receive the pointer to the last character of node string. - @retval EFI_STRING the begining of the node string. + @retval EFI_STRING the beginning of the node string. **/ EFI_STRING @@ -140,7 +140,7 @@ GetRedpathNodeByIndex ( @param[out] Index The array index number. @retval EFI_SUCCESS Index is found. - @retval EFI_NOT_FOUND The non-array configure language stri= ng is retured. + @retval EFI_NOT_FOUND The non-array configure language stri= ng is returned. @retval EFI_INVALID_PARAMETER The format of input ConfigureLang is = wrong. @retval Others Errors occur. @@ -188,7 +188,7 @@ DestroyConfiglanguageList ( @param[in] DestConfigLang Pointer to the node's configure langua= ge string. The memory pointed by ConfigLang must = be allocated - through memory allocation interface. B= ecasue we will replace + through memory allocation interface. B= ecause we will replace the pointer in this function. @param[in] MaxtLengthConfigLang The maximum length of ConfigLang. @param[in] ConfigLangInstance Pointer to Collection member instance. @@ -244,7 +244,7 @@ ApplyFeatureSettingsStringType ( /** - Apply property value to UEFI HII database in numric type. + Apply property value to UEFI HII database in numeric type. @param[in] Schema Property schema. @param[in] Version Property schema version. @@ -356,7 +356,7 @@ ApplyFeatureSettingsNumericArrayType ( @param[in] Schema Property schema. @param[in] Version Property schema version. @param[in] ConfigureLang Configure language refers to this property. - @param[in] ArrayHead Head of Redfich CS boolean array value. + @param[in] ArrayHead Head of Redfish CS boolean array value. @retval EFI_SUCCESS New value is applied successfully. @retval Others Errors occur. @@ -421,7 +421,7 @@ CreatePayloadToPatchResource ( @param[in] ConfigLang ConfigLang to save @param[in] Uri Redfish Uri to save - @retval EFI_INVALID_PARAMETR SystemId is NULL or EMPTY + @retval EFI_INVALID_PARAMETER SystemId is NULL or EMPTY @retval EFI_SUCCESS Redfish uri is saved **/ @@ -433,7 +433,7 @@ RedfisSetRedfishUri ( /** - Get the property name by given Configure Langauge. + Get the property name by given Configure Language. @param[in] ResourceUri URI of root of resource. @param[in] ConfigureLang Configure Language string. @@ -576,7 +576,7 @@ GetOdataId ( /** - Return config language from given URI and prperty name. It's call respon= sibility to release returned buffer. + Return config language from given URI and property name. It's call respo= nsibility to release returned buffer. @param[in] Uri The URI to match @param[in] PropertyName The property name of resource. This is optiona= l. @@ -790,7 +790,7 @@ MatchPropertyWithJsonContext ( /** - Create string array and append to arry node in Redfish JSON convert form= at. + Create string array and append to array node in Redfish JSON convert for= mat. @param[in,out] Head The head of string array. @param[in] StringArray Input string array. @@ -809,7 +809,7 @@ AddRedfishCharArray ( /** - Create numeric array and append to arry node in Redfish JSON convert for= mat. + Create numeric array and append to array node in Redfish JSON convert fo= rmat. @param[in,out] Head The head of string array. @param[in] NumericArray Input numeric array. @@ -828,7 +828,7 @@ AddRedfishNumericArray ( /** - Create boolean array and append to arry node in Redfish JSON convert for= mat. + Create boolean array and append to array node in Redfish JSON convert fo= rmat. @param[in,out] Head The head of string array. @param[in] BooleanArray Input boolean array. @@ -866,12 +866,34 @@ CompareRedfishStringArrayValues ( IN UINTN ArraySize ); +/** + + Check and see if value in Redfish string array can be found in HII + configuration string array. This is to see if there is any invalid + values from Redfish. + + @param[in] Head The head of string array. + @param[in] StringArray Input string array. + @param[in] ArraySize The size of StringArray. + + @retval TRUE All string in Redfish array are as same as str= ing Igor: I think here we should have a plural of "string" + @retval TRUE All strings in Redfish array are as same as st= rings + in HII configuration array. + FALSE These two array are not identical. + +**/ +BOOLEAN +ValidateRedfishStringArrayValues ( + IN RedfishCS_char_Array *Head, + IN CHAR8 **StringArray, + IN UINTN ArraySize + ); + /** Check and see if value in Redfish numeric array are all the same as the = one from HII configuration. - @param[in] Head The head of Redfish CS numeraic array. + @param[in] Head The head of Redfish CS numeric array. @param[in] NumericArray Input numeric array. @param[in] ArraySize The size of NumericArray. @@ -914,9 +936,9 @@ CompareRedfishBooleanArrayValues ( This is just a simple check. @param[in] RedfishVagueKeyValuePtr The vague key value sets on Redf= ish service. - @param[in] RedfishVagueKeyValueNumber The numebr of vague key value se= ts + @param[in] RedfishVagueKeyValueNumber The number of vague key value se= ts @param[in] ConfigVagueKeyValuePtr The vague configuration on platf= orm. - @param[in] ConfigVagueKeyValueNumber The numebr of vague key value se= ts + @param[in] ConfigVagueKeyValueNumber The number of vague key value se= ts @retval TRUE All values are the same. FALSE There is some difference. diff --git a/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatu= reUtilityLib.c b/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishF= eatureUtilityLib.c index 13e29902..a3ca1006 100644 --- a/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtili= tyLib.c +++ b/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtili= tyLib.c @@ -772,61 +772,69 @@ ApplyFeatureSettingsStringArrayType ( } // - // If there is no change in array, do nothing + // Check and see if element in request string array can be found in HII = string array. // - if (!CompareRedfishStringArrayValues (ArrayHead, RedfishValue.Value.Stri= ngArray, RedfishValue.ArrayCount)) { - // - // Apply settings from redfish - // - DEBUG ((DEBUG_MANAGEABILITY, "%a: %a.%a apply %s for array\n", __func_= _, Schema, Version, ConfigureLang)); - FreeArrayTypeRedfishValue (&RedfishValue); - + if (ValidateRedfishStringArrayValues (ArrayHead, RedfishValue.Value.Stri= ngArray, RedfishValue.ArrayCount)) { // - // Convert array from RedfishCS_char_Array to EDKII_REDFISH_VALUE + // If there is no change in array, do nothing // - RedfishValue.ArrayCount =3D 0; - Buffer =3D ArrayHead; - while (Buffer !=3D NULL) { - RedfishValue.ArrayCount +=3D 1; - Buffer =3D Buffer->Next; - } + if (!CompareRedfishStringArrayValues (ArrayHead, RedfishValue.Value.St= ringArray, RedfishValue.ArrayCount)) { + // + // Apply settings from redfish + // + DEBUG ((DEBUG_MANAGEABILITY, "%a: %a.%a apply %s for array\n", __fun= c__, Schema, Version, ConfigureLang)); + FreeArrayTypeRedfishValue (&RedfishValue); - // - // Allocate pool for new values - // - RedfishValue.Value.StringArray =3D AllocatePool (RedfishValue.ArrayCou= nt *sizeof (CHAR8 *)); - if (RedfishValue.Value.StringArray =3D=3D NULL) { - ASSERT (FALSE); - return EFI_OUT_OF_RESOURCES; - } + // + // Convert array from RedfishCS_char_Array to EDKII_REDFISH_VALUE + // + RedfishValue.ArrayCount =3D 0; + Buffer =3D ArrayHead; + while (Buffer !=3D NULL) { + RedfishValue.ArrayCount +=3D 1; + Buffer =3D Buffer->Next; + } - Buffer =3D ArrayHead; - Index =3D 0; - while (Buffer !=3D NULL) { - RedfishValue.Value.StringArray[Index] =3D AllocateCopyPool (AsciiStr= Size (Buffer->ArrayValue), Buffer->ArrayValue); - if (RedfishValue.Value.StringArray[Index] =3D=3D NULL) { + // + // Allocate pool for new values + // + RedfishValue.Value.StringArray =3D AllocatePool (RedfishValue.ArrayC= ount *sizeof (CHAR8 *)); + if (RedfishValue.Value.StringArray =3D=3D NULL) { ASSERT (FALSE); - FreePool (RedfishValue.Value.StringArray); return EFI_OUT_OF_RESOURCES; } - Buffer =3D Buffer->Next; - Index++; - } + Buffer =3D ArrayHead; + Index =3D 0; + while (Buffer !=3D NULL) { + RedfishValue.Value.StringArray[Index] =3D AllocateCopyPool (AsciiS= trSize (Buffer->ArrayValue), Buffer->ArrayValue); + if (RedfishValue.Value.StringArray[Index] =3D=3D NULL) { + ASSERT (FALSE); + FreePool (RedfishValue.Value.StringArray); + return EFI_OUT_OF_RESOURCES; + } - ASSERT (Index <=3D RedfishValue.ArrayCount); + Buffer =3D Buffer->Next; + Index++; + } - Status =3D RedfishPlatformConfigSetValue (Schema, Version, ConfigureLa= ng, RedfishValue); - if (!EFI_ERROR (Status)) { - // - // Configuration changed. Enable system reboot flag. - // - REDFISH_ENABLE_SYSTEM_REBOOT (); + ASSERT (Index <=3D RedfishValue.ArrayCount); + + Status =3D RedfishPlatformConfigSetValue (Schema, Version, Configure= Lang, RedfishValue); + if (!EFI_ERROR (Status)) { + // + // Configuration changed. Enable system reboot flag. + // + REDFISH_ENABLE_SYSTEM_REBOOT (); + } else { + DEBUG ((DEBUG_ERROR, "%a: apply %s array failed: %r\n", __func__, = ConfigureLang, Status)); + } } else { - DEBUG ((DEBUG_ERROR, "%a: apply %s array failed: %r\n", __func__, Co= nfigureLang, Status)); + DEBUG ((DEBUG_ERROR, "%a: %a.%a %s array value has no change\n", __f= unc__, Schema, Version, ConfigureLang)); } } else { - DEBUG ((DEBUG_ERROR, "%a: %a.%a %s array value has no change\n", __fun= c__, Schema, Version, ConfigureLang)); + DEBUG ((DEBUG_ERROR, "%a: %a.%a %s array value has invalid element, sk= ip!\n", __func__, Schema, Version, ConfigureLang)); + Status =3D EFI_DEVICE_ERROR; } for (Index =3D 0; Index < RedfishValue.ArrayCount; Index++) { @@ -3432,6 +3440,72 @@ CompareRedfishStringArrayValues ( return TRUE; } +/** + + Check and see if value in Redfish string array can be found in HII + configuration string array. This is to see if there is any invalid + values from Redfish. + + @param[in] Head The head of string array. + @param[in] StringArray Input string array. + @param[in] ArraySize The size of StringArray. + + @retval TRUE All string in Redfish array are as same as str= ing + in HII configuration array. + FALSE These two array are not identical. + +**/ +BOOLEAN +ValidateRedfishStringArrayValues ( + IN RedfishCS_char_Array *Head, + IN CHAR8 **StringArray, + IN UINTN ArraySize + ) +{ + UINTN Index; + UINTN InputArrayCount; + RedfishCS_char_Array *CharArrayBuffer; + + if ((Head =3D=3D NULL) || (StringArray =3D=3D NULL) || (ArraySize =3D=3D= 0)) { + return FALSE; + } + + // + // Check to see if string from Redfish can be found in string array + // returned by HII or not. If not, the input from Redfish is invalid. + // + CharArrayBuffer =3D Head; + Index =3D 0; + InputArrayCount =3D 0; + while (CharArrayBuffer !=3D NULL) { + for (Index =3D 0; Index < ArraySize; Index++) { + if (AsciiStrCmp (StringArray[Index], CharArrayBuffer->ArrayValue) = =3D=3D 0) { + break; + } + } + + if (Index =3D=3D ArraySize) { + DEBUG ((DEBUG_ERROR, "%a: input string: %a is not found in HII strin= g list\n", __func__, CharArrayBuffer->ArrayValue)); + return FALSE; + } + + InputArrayCount +=3D 1; + CharArrayBuffer =3D CharArrayBuffer->Next; + } + + // + // Check to see if the number of string from Redfish equals to the + // number of string returned by HII. HII only accepts the same + // number of string array due to the design or HII ordered list. + // + if (InputArrayCount !=3D ArraySize) { + DEBUG ((DEBUG_ERROR, "%a: input string size: %d is not the same as HII= string list size: %d\n", __func__, InputArrayCount, ArraySize)); + return FALSE; + } + + return TRUE; +} + /** Check and see if value in Redfish numeric array are all the same as the = one -- 2.17.1 -The information contained in this message may be confidential and propriet= ary to American Megatrends (AMI). This communication is intended to be read= only by the individual or entity to whom it is addressed or by their desig= nee. If the reader of this message is not the intended recipient, you are o= n notice that any distribution of this message, in any form, is strictly pr= ohibited. Please promptly notify the sender by reply e-mail or by telephone= at 770-246-8600, and then delete or destroy all copies of the transmission= . -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#110989): https://edk2.groups.io/g/devel/message/110989 Mute This Topic: https://groups.io/mt/102459779/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-