From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (NAM12-DM6-obe.outbound.protection.outlook.com [40.107.243.72]) by mx.groups.io with SMTP id smtpd.web10.89421.1684159275834502674 for ; Mon, 15 May 2023 07:01:16 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@ami.com header.s=selector1 header.b=Hf1rLg5K; spf=pass (domain: ami.com, ip: 40.107.243.72, mailfrom: igork@ami.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FjwU6226sYKuKa7rbGag4CnuI/GVqZGrqe3FHVcDbgaYuCYtglxZDNU4VuNVPBmSuvZTRBCqEUuUM1GxgbTCTspaMeeEux2VMavOYjfhzOEPbGGXbfqtySu3I4DjkodUsx6Kk0UT+8BpNrqGoI+oaNHA8viNsIpNoTLRBUmX9pJvPNRWscYPmhSF+lP+jVbKFczTZXcN9dWsXK+hopt64bDM7ebcbrtsuORtDpETjJc4t8wzRzULrP1pYTFwlCz/sd3ZigUzrUqolN4ttU1vpTJO3nfSGbpWZuKAwqivfKtl/JIxVoQo918nSnmlxymJA/AngMVjrdXmK1rJImk6GQ== 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=XvB7l2ocnm8YwAT/TjsTm5RVhvNy81RnbJN/YIIdBjI=; b=LykAfXDR13te/ip5Xpq5p2Oi9Amqs8RLQyjkZ7pTjpNcNkTHju46aMJAwYE9HaLxYLYNyb/lpnjzUP6RAb04lFGtPAbKVFcVNeTixNZEsXnNugq+Byh7jfZx0r9T56vRnMBeeos/Hw3ag4YDM+yXpUwwUA87XzrmOOaaggz3/ojJk5Xu919Kl3rILaSFF82pur5ldRckGHDCbFT4SJl1K30Tb/DsHgJHbvbCm2ZO+DiKIUQRGs0y2Tr4zJeRujztfD+o5EriInskz+EeH9aR9sbRZtur1lOOPOzrm0tlaJRwwdCqvvREYeqgWRxurUFilKgrWHVvbxoFPtyhsVPcTw== 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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ami.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=XvB7l2ocnm8YwAT/TjsTm5RVhvNy81RnbJN/YIIdBjI=; b=Hf1rLg5KrKIHJlkEaK2OVeLFTE/NevmC6fFlWBjpDCNSPJpJvCdcT55Cfi5myLlcZy00JsupMW1IuoqXUA3pz2XRIHz7Ru/E4Fjr3HWW/Qlf3ClNiZD5uGYoieQEYdgB9ABbTQ12Jzvmy1ebSqewNdqvrOfS1BjJWByDpaiz3is= Received: from BLAPR10MB5185.namprd10.prod.outlook.com (2603:10b6:208:328::16) by PH7PR10MB7720.namprd10.prod.outlook.com (2603:10b6:510:2fe::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6387.30; Mon, 15 May 2023 14:01:13 +0000 Received: from BLAPR10MB5185.namprd10.prod.outlook.com ([fe80::d79d:9060:94d8:b4b0]) by BLAPR10MB5185.namprd10.prod.outlook.com ([fe80::d79d:9060:94d8:b4b0%7]) with mapi id 15.20.6387.030; Mon, 15 May 2023 14:01:12 +0000 From: "Igor Kulchytskyy" To: Nickle Wang , "devel@edk2.groups.io" CC: Abner Chang Subject: Re: [PATCH] RedfishPkg/RedfishPlatformConfigDxe: Fix string assert issue Thread-Topic: [EXTERNAL] [PATCH] RedfishPkg/RedfishPlatformConfigDxe: Fix string assert issue Thread-Index: AQHZhuU+q+VeEtHjH0OFsx1NJ1cd1K9bXXcw Date: Mon, 15 May 2023 14:01:12 +0000 Message-ID: References: <20230515042455.4727-1-nicklew@nvidia.com> In-Reply-To: <20230515042455.4727-1-nicklew@nvidia.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=ami.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: BLAPR10MB5185:EE_|PH7PR10MB7720:EE_ x-ms-office365-filtering-correlation-id: ae2f8f60-db78-49a3-ee86-08db554cd7b2 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: O6w2w0HOALmwpzMiVStGsdC9CvblCRpJ4Hg/fjRLAoQf4kcloWIj38NFgHF9fEcPGYnhk331jXlyRS5suCJEWLnAJFYvzL2cCuZT1aXOQIufmIpoKaccDFxp3gtGOlFoOxlk5GuqonQjqG60jaAdalfO2sBE2RHibyKSM+9lDLZsh2lO1GBP5E809yNKc0LJjNJ/E585BHpf76JU+zbsa0dSGptdFR8nk3hDsOsdvTxD9cZb8SFZhKbhk0xLALiYTdI70WUQlaGZAlYTkDBvHLcY0nJn/x98gpOa5AhaekGXxywvEX9Shua+WbwiPsMIpVSsE+VJ7d0s3rL0NeMukJ+iNIQwY1DIM2yT3JYHU1U1/j44V/v6iOKV4JVJEjPLug0A0M2hep+udVebTMxzYIl4NbiVMSQZ2Wz+rfUO7rw5Cg9p0NGxiKDk1jhfKSP30axRw+FBOXyv9sAZA70vRCxcgzc0ixvAJguk3CV7lvz6SVxva7T2yVwSlhqXeV616WK2lAij7LYpz4SwyxwQUURQ/TZntXFpDzF4SkiWj0PF8puBpBDkX62zj36y5LR2cUp3c1PZ5BHAgvSkX5Xiu1zTuXrJcZqoqHhBZWAjYgRAlvEEYSOCpEXUM30Q/Cwn x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BLAPR10MB5185.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(366004)(136003)(346002)(376002)(396003)(39850400004)(451199021)(33656002)(40140700001)(86362001)(110136005)(316002)(64756008)(66946007)(66476007)(4326008)(66446008)(66556008)(478600001)(76116006)(7696005)(55016003)(5660300002)(52536014)(8676002)(8936002)(30864003)(2906002)(38070700005)(38100700002)(122000001)(41300700001)(186003)(53546011)(26005)(6506007)(9686003)(83380400001)(71200400001);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?5lGk1FCQni3RvT/3IsNEEL/JOXvPWU04o0sD0bP0JZ5kGHb0R2cUc0EOQADG?= =?us-ascii?Q?WRN6+nfOtczP16E422abxzer7Yj/84WJVlhlNIasXsjUdremMTG5NSzX1/5e?= =?us-ascii?Q?p01IJTb70tIX2t7JiatnV6xQwmHJu0KjtX1xlMw9LK1nkTZdzk+cmYXLssyP?= =?us-ascii?Q?RwYhqItZ4169kET9kawvPxJaI/KjPaPTlMbI7K4Qf5nylikxf2eeI4eCg9JY?= =?us-ascii?Q?gJwnQDCP47EPt+KCtw2sVAROL2ULzU9oCXNpCaCoH6FTMcpPyg8hhW3K6RdM?= =?us-ascii?Q?lojQprEwfOXduPmbGvd2BJggVWfDwsp9sVuQIB9l1mHztD89ZSBSDwvdkzN6?= =?us-ascii?Q?3iOBkaLMQTPsPDZCw3b0A2qgKN2vovEMZ6xzmtSWprRrl4CQUWRwY0i9A62I?= =?us-ascii?Q?Rb8CChjVEQLI7UWdOqu9MeGbvwWnJktqG+jhtQlvrhkpfzwl5c4CwLQhqZzi?= =?us-ascii?Q?uWALB+wCXJjCMIxlNSiDhpmQ0DpILYxyyU/MJoEn92Oh389wJiu3Gey2+a/v?= =?us-ascii?Q?eBhrShqLNOWci8nRD1QLOQPBOi1r4rfbTNNTKPNGPbGLU8y/jteSdW2rasNM?= =?us-ascii?Q?++m1hiHf3h3qO9ScDNlHT8PurkJQ55nq5jFP6Tcqp9FiAaRTTJuiAZ/WBKgV?= =?us-ascii?Q?MHfLMoRLa+LjvNjuYNkDdXepxHyN1/tvtRYWvl8n1w8M15fwGYKCa8ynHPmx?= =?us-ascii?Q?HXCtay6MB1rDykZIToZpyvQ+ohScr4/i4Tt6uTPuQtpi/cqTDv3CAG7aYcoJ?= =?us-ascii?Q?hmirogo8rwUkHrFsbljled2Bu0ImEiGKKlHDdMmShSLPqHyfCe365I1Z6LwB?= =?us-ascii?Q?ZXPzRnwjIvcSW6ccUh92xKeYK2lt8nbuFX6YimWAzWtDHYyzsCpdnR63+qPu?= =?us-ascii?Q?hx/SO868oBzKklbjHodFuWE/1r+9ElpIufiB21DqCBlWW5YbrJCUNqcfk1aO?= =?us-ascii?Q?C/jGOoRipmvlnt/4PLAXuazS336R9JvWw5A9WyFNxKU2eRuxC+glqWWVW59V?= =?us-ascii?Q?KFcaYenIpbweGuVR1jpM8Fo1dKhIVnWictHV4EPHP1rCveeJnvF+6H5sNSCl?= =?us-ascii?Q?pE2sKcIhGLTgh0KwBay4jDuCxE8rTJJsGC1fm35tRpCVND0+fhFIUWLmxoXr?= =?us-ascii?Q?bW/6Oxqd9efona9gcA6KBLCsvAgSbdv2+9Jh75xsjznxH4AKBjDE6c+fNAml?= =?us-ascii?Q?p3DCBd237UGC5WMYxyaFCOIpPGEq9dkwj8lbnPZuN6f2ztkPtVjltUinH95e?= =?us-ascii?Q?22IaHP4rSwlBv9zLbamSnCdRpV1LITeNIVCmkjOYAc8msrzCiciRMmo2tgt5?= =?us-ascii?Q?8YmbdNRSKc2JU5eelBnJM601OODfJDrRFVWw6JBUQ1QXtVdCia3/S/KJv9dH?= =?us-ascii?Q?jA7n24Zu9K+Bw2xN2RIDIpGZAc5LZClXugmvf4c7bQPIo0VrDE8DF4Ie+HAV?= =?us-ascii?Q?q1KvwfhwFYy+jY2/RboIt4CUlGSw4GAmric5u4mVVhYDRzfO6L/rf/VjL1v1?= =?us-ascii?Q?OndAihTIMEAk6lj4zYTl2x1o/13PfybAMtff5cxDY1Gmvi25LPxZdDd+mBb+?= =?us-ascii?Q?4xTKhuV8+pdSA6hOUig=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: ae2f8f60-db78-49a3-ee86-08db554cd7b2 X-MS-Exchange-CrossTenant-originalarrivaltime: 15 May 2023 14:01:12.7647 (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: v+dNqkIfFeUWZdrMXUpSF8sI6Cpq8gt2pIcuPI4s9Msr996iOqTNPCU4ju78tbnt X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR10MB7720 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Igor Kulchytskyy -----Original Message----- From: Nickle Wang Sent: Monday, May 15, 2023 12:25 AM To: devel@edk2.groups.io Cc: Abner Chang ; Igor Kulchytskyy Subject: [EXTERNAL] [PATCH] RedfishPkg/RedfishPlatformConfigDxe: Fix string= assert issue **CAUTION: The e-mail below is from an external source. Please exercise cau= tion before opening attachments, clicking links, or following guidance.** When calling SetValue() with string type input, there is assertion of providing zero string ID to HII string function. Fix this issue by creating string ID for input string buffer. Fix Unicode and Ascii code convert issue together. Add text op-code support Signed-off-by: Nickle Wang Cc: Abner Chang Cc: Igor Kulchytskyy --- .../RedfishPlatformConfigDxe.h | 14 +++ .../RedfishPlatformConfigImpl.h | 16 +++ .../RedfishPlatformConfigDxe.c | 116 ++++++++++++++++-- .../RedfishPlatformConfigImpl.c | 50 +++++--- 4 files changed, 169 insertions(+), 27 deletions(-) diff --git a/RedfishPkg/RedfishPlatformConfigDxe/RedfishPlatformConfigDxe.h= b/RedfishPkg/RedfishPlatformConfigDxe/RedfishPlatformConfigDxe.h index 67697ecda787..c86bc6e9ce2d 100644 --- a/RedfishPkg/RedfishPlatformConfigDxe/RedfishPlatformConfigDxe.h +++ b/RedfishPkg/RedfishPlatformConfigDxe/RedfishPlatformConfigDxe.h @@ -78,4 +78,18 @@ typedef struct { #define REDFISH_PLATFORM_CONFIG_DEBUG DEBUG_VERBOSE #define REDFISH_MENU_PATH_SIZE 8 +/** + Convert input unicode string to ascii string. It's caller's + responsibility to free returned buffer using FreePool(). + + @param[in] UnicodeString Unicode string to be converted. + + @retval CHAR8 * Ascii string on return. + +**/ +CHAR8 * +StrToAsciiStr ( + IN EFI_STRING UnicodeString + ); + #endif diff --git a/RedfishPkg/RedfishPlatformConfigDxe/RedfishPlatformConfigImpl.= h b/RedfishPkg/RedfishPlatformConfigDxe/RedfishPlatformConfigImpl.h index 9ef032748663..9f4312decf50 100644 --- a/RedfishPkg/RedfishPlatformConfigDxe/RedfishPlatformConfigImpl.h +++ b/RedfishPkg/RedfishPlatformConfigDxe/RedfishPlatformConfigImpl.h @@ -250,6 +250,22 @@ ProcessPendingList ( IN LIST_ENTRY *PendingList ); +/** + Delete a string from HII Package List by given HiiHandle. + + @param[in] StringId Id of the string in HII database. + @param[in] HiiHandle The HII package list handle. + + @retval EFI_SUCCESS The string was deleted successfully. + @retval EFI_INVALID_PARAMETER StringId is zero. + +**/ +EFI_STATUS +HiiDeleteString ( + IN EFI_STRING_ID StringId, + IN EFI_HII_HANDLE HiiHandle + ); + /** Retrieves a unicode string from a string package in a given language. Th= e returned string is allocated using AllocatePool(). The caller is respon= sible diff --git a/RedfishPkg/RedfishPlatformConfigDxe/RedfishPlatformConfigDxe.c= b/RedfishPkg/RedfishPlatformConfigDxe/RedfishPlatformConfigDxe.c index d3902f4127c1..1172d1094b06 100644 --- a/RedfishPkg/RedfishPlatformConfigDxe/RedfishPlatformConfigDxe.c +++ b/RedfishPkg/RedfishPlatformConfigDxe/RedfishPlatformConfigDxe.c @@ -1172,6 +1172,7 @@ HiiValueToRedfishValue ( UINTN Index; UINTN Count; EFI_STRING_ID *StringIdArray; + CHAR8 NullChar; if ((HiiHandle =3D=3D NULL) || (HiiStatement =3D=3D NULL) || (Value =3D= =3D NULL) || (RedfishValue =3D=3D NULL) || IS_EMPTY_STRING (FullSchema)) { return EFI_INVALID_PARAMETER; @@ -1180,6 +1181,7 @@ HiiValueToRedfishValue ( StringIdArray =3D NULL; Count =3D 0; Status =3D EFI_SUCCESS; + NullChar =3D '\0'; switch (HiiStatement->Operand) { case EFI_IFR_ONE_OF_OP: @@ -1205,9 +1207,18 @@ HiiValueToRedfishValue ( break; } - RedfishValue->Type =3D RedfishValueTypeString; - RedfishValue->Value.Buffer =3D AllocatePool (StrLen ((CHAR16 *)Value= ->Buffer) + 1); - UnicodeStrToAsciiStrS ((CHAR16 *)Value->Buffer, RedfishValue->Value.= Buffer, StrLen ((CHAR16 *)Value->Buffer) + 1); + if (Value->Buffer =3D=3D NULL) { + RedfishValue->Value.Buffer =3D AllocateCopyPool (sizeof (NullChar)= , &NullChar); + } else { + RedfishValue->Value.Buffer =3D StrToAsciiStr ((EFI_STRING)Value->B= uffer); + } + + if (RedfishValue->Value.Buffer =3D=3D NULL) { + Status =3D EFI_OUT_OF_RESOURCES; + break; + } + + RedfishValue->Type =3D RedfishValueTypeString; break; case EFI_IFR_CHECKBOX_OP: case EFI_IFR_NUMERIC_OP: @@ -1256,6 +1267,30 @@ HiiValueToRedfishValue ( FreePool (StringIdArray); break; + case EFI_IFR_TEXT_OP: + // + // Use text two as the value + // + if (HiiStatement->ExtraData.TextTwo =3D=3D 0x00) { + Status =3D EFI_NOT_FOUND; + break; + } + + RedfishValue->Value.Buffer =3D HiiGetRedfishAsciiString (HiiHandle, = FullSchema, HiiStatement->ExtraData.TextTwo); + if (RedfishValue->Value.Buffer =3D=3D NULL) { + // + // No x-uefi-redfish string defined. Try to get string in English. + // + RedfishValue->Value.Buffer =3D HiiGetEnglishAsciiString (HiiHandle= , HiiStatement->ExtraData.TextTwo); + } + + if (RedfishValue->Value.Buffer =3D=3D NULL) { + Status =3D EFI_OUT_OF_RESOURCES; + break; + } + + RedfishValue->Type =3D RedfishValueTypeString; + break; default: DEBUG ((DEBUG_ERROR, "%a: catch unsupported type: 0x%x! Please conta= ct with author if we need to support this type.\n", __func__, HiiStatement-= >Operand)); ASSERT (FALSE); @@ -1284,7 +1319,7 @@ StrToUnicodeStr ( EFI_STRING Buffer; EFI_STATUS Status; - if ((AsciiString =3D=3D NULL) || (AsciiString[0] =3D=3D '\0')) { + if (AsciiString =3D=3D NULL) { return NULL; } @@ -1303,6 +1338,43 @@ StrToUnicodeStr ( return Buffer; } +/** + Convert input unicode string to ascii string. It's caller's + responsibility to free returned buffer using FreePool(). + + @param[in] UnicodeString Unicode string to be converted. + + @retval CHAR8 * Ascii string on return. + +**/ +CHAR8 * +StrToAsciiStr ( + IN EFI_STRING UnicodeString + ) +{ + UINTN StringLen; + CHAR8 *Buffer; + EFI_STATUS Status; + + if (UnicodeString =3D=3D NULL) { + return NULL; + } + + StringLen =3D StrLen (UnicodeString) + 1; + Buffer =3D AllocatePool (StringLen * sizeof (CHAR8)); + if (Buffer =3D=3D NULL) { + return NULL; + } + + Status =3D UnicodeStrToAsciiStrS (UnicodeString, Buffer, StringLen); + if (EFI_ERROR (Status)) { + FreePool (Buffer); + return NULL; + } + + return Buffer; +} + /** Return the full Redfish schema string from the given Schema and Version. @@ -1641,6 +1713,17 @@ RedfishPlatformConfigSetStatementCommon ( } } + if ((TargetStatement->HiiStatement->Operand =3D=3D EFI_IFR_STRING_OP) &&= (StatementValue->Type =3D=3D EFI_IFR_TYPE_STRING)) { + // + // Create string ID for new string. + // + StatementValue->Value.string =3D HiiSetString (TargetStatement->Parent= Form->ParentFormset->HiiHandle, 0x00, (EFI_STRING)StatementValue->Buffer, N= ULL); + if (StatementValue->Value.string =3D=3D 0) { + DEBUG ((DEBUG_ERROR, "%a: can not create string id\n", __func__)); + return EFI_OUT_OF_RESOURCES; + } + } + Status =3D RedfishPlatformConfigSaveQuestionValue ( TargetStatement->ParentForm->ParentFormset->HiiFormSet, TargetStatement->ParentForm->HiiForm, @@ -1649,10 +1732,13 @@ RedfishPlatformConfigSetStatementCommon ( ); if (EFI_ERROR (Status)) { DEBUG ((DEBUG_ERROR, "%a: failed to save question value: %r\n", __func= __, Status)); - return Status; } - return EFI_SUCCESS; + if (StatementValue->Value.string !=3D 0) { + HiiDeleteString (StatementValue->Value.string, TargetStatement->Parent= Form->ParentFormset->HiiHandle); + } + + return Status; } /** @@ -1712,9 +1798,14 @@ RedfishPlatformConfigProtocolSetValue ( break; case RedfishValueTypeString: + if (Value.Value.Buffer =3D=3D NULL) { + Status =3D EFI_INVALID_PARAMETER; + goto RELEASE_RESOURCE; + } + NewValue.Type =3D EFI_IFR_TYPE_STRING; - NewValue.BufferLen =3D (UINT16)AsciiStrSize (Value.Value.Buffer); - NewValue.Buffer =3D AllocateCopyPool (NewValue.BufferLen, Value.V= alue.Buffer); + NewValue.BufferLen =3D (UINT16)(AsciiStrSize (Value.Value.Buffer) * = sizeof (CHAR16)); + NewValue.Buffer =3D (UINT8 *)StrToUnicodeStr (Value.Value.Buffer)= ; if (NewValue.Buffer =3D=3D NULL) { Status =3D EFI_OUT_OF_RESOURCES; goto RELEASE_RESOURCE; @@ -1742,6 +1833,10 @@ RELEASE_RESOURCE: FreePool (FullSchema); } + if ((Value.Type =3D=3D RedfishValueTypeString) && (NewValue.Buffer !=3D = NULL)) { + FreePool (NewValue.Buffer); + } + return Status; } @@ -1784,6 +1879,7 @@ RedfishPlatformConfigProtocolGetConfigureLang ( return EFI_INVALID_PARAMETER; } + ZeroMem (&StatementList, sizeof (StatementList)); *Count =3D 0; *ConfigureLangList =3D NULL; FullSchema =3D NULL; @@ -1849,7 +1945,9 @@ RELEASE_RESOURCE: FreePool (FullSchema); } - ReleaseStatementList (&StatementList); + if (StatementList.Count > 0) { + ReleaseStatementList (&StatementList); + } return Status; } diff --git a/RedfishPkg/RedfishPlatformConfigDxe/RedfishPlatformConfigImpl.= c b/RedfishPkg/RedfishPlatformConfigDxe/RedfishPlatformConfigImpl.c index 889448fe3870..e4a905aec44e 100644 --- a/RedfishPkg/RedfishPlatformConfigDxe/RedfishPlatformConfigImpl.c +++ b/RedfishPkg/RedfishPlatformConfigDxe/RedfishPlatformConfigImpl.c @@ -143,6 +143,34 @@ DumpFormsetList ( return EFI_SUCCESS; } +/** + Delete a string from HII Package List by given HiiHandle. + + @param[in] StringId Id of the string in HII database. + @param[in] HiiHandle The HII package list handle. + + @retval EFI_SUCCESS The string was deleted successfully. + @retval EFI_INVALID_PARAMETER StringId is zero. + +**/ +EFI_STATUS +HiiDeleteString ( + IN EFI_STRING_ID StringId, + IN EFI_HII_HANDLE HiiHandle + ) +{ + CHAR16 NullChar; + + if (StringId =3D=3D 0x00) { + return EFI_INVALID_PARAMETER; + } + + NullChar =3D CHAR_NULL; + HiiSetString (HiiHandle, StringId, &NullChar, NULL); + + return EFI_SUCCESS; +} + /** Retrieves a unicode string from a string package in a given language. Th= e returned string is allocated using AllocatePool(). The caller is respon= sible @@ -259,7 +287,6 @@ HiiGetRedfishAsciiString ( ) { EFI_STRING HiiString; - UINTN StringSize; CHAR8 *AsciiString; HiiString =3D HiiGetRedfishString (HiiHandle, Language, StringId); @@ -268,15 +295,9 @@ HiiGetRedfishAsciiString ( return NULL; } - StringSize =3D (StrLen (HiiString) + 1) * sizeof (CHAR8); - AsciiString =3D AllocatePool (StringSize); - if (AsciiString =3D=3D NULL) { - return NULL; - } - - UnicodeStrToAsciiStrS (HiiString, AsciiString, StringSize); - + AsciiString =3D StrToAsciiStr (HiiString); FreePool (HiiString); + return AsciiString; } @@ -322,7 +343,6 @@ HiiGetEnglishAsciiString ( ) { EFI_STRING HiiString; - UINTN StringSize; CHAR8 *AsciiString; HiiString =3D HiiGetRedfishString (HiiHandle, ENGLISH_LANGUAGE_CODE, Str= ingId); @@ -331,15 +351,9 @@ HiiGetEnglishAsciiString ( return NULL; } - StringSize =3D (StrLen (HiiString) + 1) * sizeof (CHAR8); - AsciiString =3D AllocatePool (StringSize); - if (AsciiString =3D=3D NULL) { - return NULL; - } - - UnicodeStrToAsciiStrS (HiiString, AsciiString, StringSize); - + AsciiString =3D StrToAsciiStr (HiiString); FreePool (HiiString); + return AsciiString; } -- 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= .