From nobody Thu May 16 04:01:56 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+110901+1787277+3901457@groups.io; arc=fail (BodyHash is different from the expected one) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 16994282883951023.1631738880903; Tue, 7 Nov 2023 23:24:48 -0800 (PST) Return-Path: DKIM-Signature: a=rsa-sha256; bh=TQ+QlXE0D6cH1HGI4cXb0T2J2k0vLRT2KJtIYIzbKbY=; c=relaxed/simple; d=groups.io; h=ARC-Seal:ARC-Message-Signature:ARC-Authentication-Results:Received-SPF:From:To:CC:Subject:Date:Message-ID:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding:Content-Type; s=20140610; t=1699428288; v=1; b=u98cHtTxAV8e1p3srsmnyNKARaAjh7zUf+UvRg0RXaeerh+cqHm5NhV87z1KTUK9qbtOXp1c KD48KK27cttH0fBKqoqFpT302PGpvvcn2yyhfq7hwsWOQIEBVUYBK8ksqxU0X3IfWNSjpmqFTma uJxoGtXylinlOSxHfW3C7bVY= X-Received: by 127.0.0.2 with SMTP id dgydYY1788612xlkRaPfJ18y; Tue, 07 Nov 2023 23:24:48 -0800 X-Received: from NAM11-BN8-obe.outbound.protection.outlook.com (NAM11-BN8-obe.outbound.protection.outlook.com [40.107.236.41]) by mx.groups.io with SMTP id smtpd.web11.8756.1699428287089928724 for ; Tue, 07 Nov 2023 23:24:47 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZR8tnRSfz8vTinQ90p12OL0gF3GCl0NQlQucHEWF0JfX8w0sqpgExI7vfmjnSOwBTH75V5wz9QinFePCZd5kqj2GJMYeSZaKhSnOpfuTmcMK0xYDBdeosha3eqEj740IiPsN8y5l5O4hRytTPwwpPEqjisAIqDyZYpicwb5zhdusJNZVFv/a8JCvehkDnLPbcF7jZSoFdM4yle1bdSoXR//0A3fdDN91W/5tT0WSrCEwj1coYTrbNk3VDvETlZBCg+ZjjLjnTyF64NvGeDPB3Wqo7hMjwTmk2DNY/5EGhUB97WoJPCyG4AkRNCWIcJ/kqxyTkkYESc07e/rK7CAqJA== 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=wsURKKHDv4k4QBGNDG4pjgKlEBQtWNbwjcgnTQQffnE=; b=K9BpeA4sNAE7nCxyKoqEukV5YZZ75/0ShBWkj/0Z5uCdq6OyNRtJi4cP8xONtmxhbtR3iN/o792wIQcVDfJkW2kIlO4sETTRsGryWcZzf2SxT/RtVZ5QJ+Q7Ak/Jencb1XZYnCBC9bpqvis2pECRk+ci8OgSBdscyZzOZ5g5vw/q9uhc5eUum2JGfku8WGGhYN4h1NQgqiD5EcKkGYuXzdBh9NTZu8IbYa0DRF6hBBAd8SluuLxfS9w27Z6oZXK7/JMaO1h/TLpLX5Q22X5sp960wXCTF7rv+Bs3iwIROk6HQCTDOuCQ38MmezE9A6jUKorRgynwkrPFNZvJqWVsDA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.118.233) smtp.rcpttodomain=edk2.groups.io smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) X-Received: from DM5PR08CA0033.namprd08.prod.outlook.com (2603:10b6:4:60::22) by MN2PR12MB4126.namprd12.prod.outlook.com (2603:10b6:208:199::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6954.28; Wed, 8 Nov 2023 07:24:44 +0000 X-Received: from DS1PEPF00017090.namprd03.prod.outlook.com (2603:10b6:4:60:cafe::43) by DM5PR08CA0033.outlook.office365.com (2603:10b6:4:60::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6977.18 via Frontend Transport; Wed, 8 Nov 2023 07:24:44 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.118.233) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+110901+1787277+3901457@groups.io; helo=mail02.groups.io; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.118.233 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.118.233; helo=mail.nvidia.com; pr=C X-Received: from mail.nvidia.com (216.228.118.233) by DS1PEPF00017090.mail.protection.outlook.com (10.167.17.132) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6977.16 via Frontend Transport; Wed, 8 Nov 2023 07:24:43 +0000 X-Received: from drhqmail203.nvidia.com (10.126.190.182) by mail.nvidia.com (10.127.129.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Tue, 7 Nov 2023 23:24:34 -0800 X-Received: from drhqmail203.nvidia.com (10.126.190.182) by drhqmail203.nvidia.com (10.126.190.182) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Tue, 7 Nov 2023 23:24:34 -0800 X-Received: from NV-CL38DL3.nvidia.com (10.127.8.12) by mail.nvidia.com (10.126.190.182) with Microsoft SMTP Server id 15.2.986.41 via Frontend Transport; Tue, 7 Nov 2023 23:24:33 -0800 From: "Nickle Wang via groups.io" To: CC: Abner Chang , Igor Kulchytskyy , "Nick Ramirez" Subject: [edk2-devel] [edk2-redfish-client][PATCH] RedfishClientPkg/RedfishFeatureUtilityLib: validate string array Date: Wed, 8 Nov 2023 15:24:33 +0800 Message-ID: <20231108072433.90-1-nicklew@nvidia.com> MIME-Version: 1.0 X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS1PEPF00017090:EE_|MN2PR12MB4126:EE_ X-MS-Office365-Filtering-Correlation-Id: 831e0363-ff46-4397-e93b-08dbe02bc787 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Message-Info: Iw7168iNJALi0MSZWRjDokfC9GEBSTga4y3W2USECEYah4kGcsFXdsSBgSj/P1Pxry3rv14a39sX+YsRo8PN99p3ggVP2QfSrd8c00l2m01lysFqWjDoh8/fz4XKDTnQJrIjDp92NvHJUwf5u8/7VD1GyjL+j4cyVg+jVngK69GRwOU1pL1UocjdsJQqLUd6uIkKTdfBLhPfeqp/178sCFulSiy3FWaPqo9p3P4GL8zfQcAWfa7QJlEBCIje0d1ZwWHEBaOn6HwfqpnUx/uz5c17s/TExBsI82DDco3os9x8+h5C0wZvGoRBG5S/GlArqOG0N48pmN6RDudNVhmFASMmuw28iiPPwKoK7iPS6anYwHA+qJDFkkYgtUlm0s6h1Z3FNkQmt4UErVFDxuYjMSsAPS2plTUFhrXAwAaXu4KDVUkNgTAGcfzqm6cGEmpRuaNrt/QmjEH9xNkADiZMEWbgEvwrIG/TGBh0LsUCbrSuzY6j5rPV0tgpMLv2/d1UyT4aB8a+GSJ37QVwr1AEssVCUlz43W7+zGApfp2ZF0O+jFPbGYYhJAUttuhatt0ezBlOLDP0fB9dGxAmQ4H41tEAHAZUxG3ezFz1N0JMKsWPuNkpVLbMSNCN02rwiTmM0IJEuANbjdOtCj5t3D2f1l3STPqPAJA8QaXSE8hon1Jca8zG8vQDxHNtaoSAhDilyLYeX2JJShduyjibDmg6vdV56MmDV6PrO0RsjgNptfkkc6BFcX4O/0oEtkrjoypv X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Nov 2023 07:24:43.7445 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 831e0363-ff46-4397-e93b-08dbe02bc787 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.118.233];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DS1PEPF00017090.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4126 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,nicklew@nvidia.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: xmNK22NtGRo04kpUNWCNYr77x1787277AA= Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1699428289035100001 Content-Type: text/plain; charset="utf-8" - 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 @@ =20 Read redfish resource by given resource URI. =20 - @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. =20 @@ -47,7 +47,7 @@ GetResourceByUri ( @param[out] ArraySignatureClose String to the close of array signa= ture. =20 @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. =20 @@ -118,10 +118,10 @@ GetNumberOfRedpathNodes ( =20 @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. =20 - @retval EFI_STRING the begining of the node string. + @retval EFI_STRING the beginning of the node string. =20 **/ EFI_STRING @@ -140,7 +140,7 @@ GetRedpathNodeByIndex ( @param[out] Index The array index number. =20 @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. =20 @@ -188,7 +188,7 @@ DestroyConfiglanguageList ( =20 @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 ( =20 /** =20 - Apply property value to UEFI HII database in numric type. + Apply property value to UEFI HII database in numeric type. =20 @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. =20 @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 =20 - @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 =20 **/ @@ -433,7 +433,7 @@ RedfisSetRedfishUri ( =20 /** =20 - Get the property name by given Configure Langauge. + Get the property name by given Configure Language. =20 @param[in] ResourceUri URI of root of resource. @param[in] ConfigureLang Configure Language string. @@ -576,7 +576,7 @@ GetOdataId ( =20 /** =20 - 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. =20 @param[in] Uri The URI to match @param[in] PropertyName The property name of resource. This is optiona= l. @@ -790,7 +790,7 @@ MatchPropertyWithJsonContext ( =20 /** =20 - 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. =20 @param[in,out] Head The head of string array. @param[in] StringArray Input string array. @@ -809,7 +809,7 @@ AddRedfishCharArray ( =20 /** =20 - 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. =20 @param[in,out] Head The head of string array. @param[in] NumericArray Input numeric array. @@ -828,7 +828,7 @@ AddRedfishNumericArray ( =20 /** =20 - 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. =20 @param[in,out] Head The head of string array. @param[in] BooleanArray Input boolean array. @@ -866,12 +866,34 @@ CompareRedfishStringArrayValues ( IN UINTN ArraySize ); =20 +/** + + 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 + ); + /** =20 Check and see if value in Redfish numeric array are all the same as the = one from HII configuration. =20 - @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. =20 @@ -914,9 +936,9 @@ CompareRedfishBooleanArrayValues ( This is just a simple check. =20 @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 =20 @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 ( } =20 // - // 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); =20 - // - // 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; + } =20 - 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; } =20 - 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; + } =20 - ASSERT (Index <=3D RedfishValue.ArrayCount); + Buffer =3D Buffer->Next; + Index++; + } =20 - 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; } =20 for (Index =3D 0; Index < RedfishValue.ArrayCount; Index++) { @@ -3432,6 +3440,72 @@ CompareRedfishStringArrayValues ( return TRUE; } =20 +/** + + 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; +} + /** =20 Check and see if value in Redfish numeric array are all the same as the = one --=20 2.17.1 -=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 (#110901): https://edk2.groups.io/g/devel/message/110901 Mute This Topic: https://groups.io/mt/102459779/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-