From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (NAM10-DM6-obe.outbound.protection.outlook.com [40.107.93.44]) by mx.groups.io with SMTP id smtpd.web11.81236.1684126139473098584 for ; Sun, 14 May 2023 21:48:59 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@amd.com header.s=selector1 header.b=NDXF80SU; spf=permerror, err=parse error for token &{10 18 %{i}._ip.%{h}._ehlo.%{d}._spf.vali.email}: invalid domain name (domain: amd.com, ip: 40.107.93.44, mailfrom: abner.chang@amd.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RxnIgsiWO/7/NGnE3DKcOcCYNzpZvHE/kkJiRnrZWMPKWQOmO0K0QKiPY1pPIEnV8u5NO31vgaWFyMo7ZVcrKeA5A2TXPZRsNvx2u9z1Zobxv1cEgDskvgV19d29cR5O5dCMhV/QEjl7NT/4mhdVn9Cj2CHrNAdnbPlraj73ojytPi4TDNdLfvu0SYX0j74GzoQiMglQyW6L7f/tHIIP/GpYIYWrZQEx9u8ZsFQQ15AYhCGN7M9exl1VfkL/C86DnkpxAxxkiQxrLa5qT3ZdW3yAHSo8iESJwZsgTGd7M312hijEWlCChSFd2UKPGDXTvzN43RS6mXyjPkvejBsu9g== 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=9yzBzqq3tkI5apBpkZO9NbwQ3dszUrph9eC4KeXIBIA=; b=eJr2J1Tw2sjrFbRuEpRCRhqordktgInfWiew4A+98SApznvlK1gwumukBit5JA1+Sxj30+wVlGTCq3E0xzcN8IhHQD39Tc99kEMkP2yh/+w0Tjvqwe87KdrYZ6PItNQlwfEG91HywhA/eVuKh3xGLwRbX6HN8zc4675buZf/bHZZ61XP8erSs8bOvR+aEifcOvPBKLILp5NrMa4hvTWBW0CZFovJYgoaFtZA16OrIcj+/kQDlaMYWY/+jUxMfxKAKUWY4xGy9AjbMYn7y1K5Qm8PQX8sBxGbME4K99FHeuc88EjRRDADXAisK9AQgbaMvc1mZ+Qtf44jmYQX2EN77A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=9yzBzqq3tkI5apBpkZO9NbwQ3dszUrph9eC4KeXIBIA=; b=NDXF80SUKSUSj9ABdIccgQNFC1jqIFRargP1Xjxvkb4RaG/7Tm0WT6BEfdMZWWh1qdgOwMJj9yYTiixwCXtoy/TOxX0b1iovWt2jAoo2MDrSCH9t76gYeCwKBilvVPVRPmP+L4pBTtSjUUoyl1THWudfWzvJogmvxJLt92McYWk= Received: from CH2PR12MB3957.namprd12.prod.outlook.com (2603:10b6:610:2c::17) by SA0PR12MB7001.namprd12.prod.outlook.com (2603:10b6:806:2c0::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 04:48:56 +0000 Received: from CH2PR12MB3957.namprd12.prod.outlook.com ([fe80::451d:b6f7:85e2:f12b]) by CH2PR12MB3957.namprd12.prod.outlook.com ([fe80::451d:b6f7:85e2:f12b%4]) with mapi id 15.20.6387.030; Mon, 15 May 2023 04:48:55 +0000 From: "Chang, Abner" To: Nickle Wang , "devel@edk2.groups.io" CC: Igor Kulchytskyy Subject: Re: [PATCH] RedfishPkg/RedfishPlatformConfigDxe: Fix string assert issue Thread-Topic: [PATCH] RedfishPkg/RedfishPlatformConfigDxe: Fix string assert issue Thread-Index: AQHZhuU9N2DkraJVukqBc6ILxB6mx69awz9g Date: Mon, 15 May 2023 04:48:54 +0000 Message-ID: References: <20230515042455.4727-1-nicklew@nvidia.com> In-Reply-To: <20230515042455.4727-1-nicklew@nvidia.com> Accept-Language: zh-CN, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_Enabled=true; MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_SetDate=2023-05-15T04:48:53Z; MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_Method=Standard; MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_Name=General; MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_SiteId=3dd8961f-e488-4e60-8e11-a82d994e183d; MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_ActionId=3b56af0c-1006-43be-86f4-3fa1ea2005e3; MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_ContentBits=1 authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: CH2PR12MB3957:EE_|SA0PR12MB7001:EE_ x-ms-office365-filtering-correlation-id: ea3363d0-1b86-451d-684a-08db54ffb014 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: 5XLAnsGgHuOO7G2OeStmtFyf8fLwDMyX4zyuMF8TBw8MifMZQQqHUfNsiA/HFAG57S7hmwwSUGnD571IqAg6Jzrs6bmlLTyQAZCkHAmsQ6DDk4CA08CMpZqDm7XiS34XktcOKCvtyv6BYbtSYsMLrgAHMFRZrjM3K5RHDDfI91Ef9bVu6k1AXvMo31ynSBGYrDioowyC/jQ6wYeG/gxSTWwneLF0OKpDPfvXM3Uj1ayxPBAaApm0/lANl6vsAULPg990e4Pfa+V6rEVMNa7ubDgtsfZunL7K+lqx3P6kLAxsKiO1d4McpGkN33PalrQM351CZ+tekMkr32I+dBNfGaFlEYZsO7uGs0DBB4Vrx7nkjwjjo7bI3DVfUbt4DgsvDVl9Vw4ePr4Mr9zE1uHjlSQt8ex+Z6AHO7fLi2dOIa5OkLjRpeYuvByUgqquYJ964z6+0iG1KrMqsFYncF3m9GyA++7d8UPiNdVqdjsiqXOlJJW54SD5DQjjQWVtfVI61Lbil1hLPG7E9k49RudOUd1M2M547zcbeaerISZSv7HUQLHIoqOqliusFHqUXl2Z0DONaMvtQJ9fsZA/Fe3ABL3iycrdkwDhy77C09D6av02INoNn2EJNCHPxnMor7TZ x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CH2PR12MB3957.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(39860400002)(346002)(376002)(136003)(366004)(396003)(451199021)(66556008)(66476007)(66446008)(64756008)(4326008)(478600001)(76116006)(66946007)(110136005)(6506007)(186003)(53546011)(9686003)(38100700002)(38070700005)(83380400001)(8936002)(8676002)(2906002)(55016003)(71200400001)(7696005)(316002)(86362001)(122000001)(33656002)(5660300002)(30864003)(41300700001)(52536014)(26005);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?+fXOyN/oN/7JYIyEBEMQGRNkAdj9AKTUf0UTo+g49ZkODB6YelevFQ5aJdVb?= =?us-ascii?Q?DLLY0C2jPDOH5wCWhh27Jr6S34avtbYTC31m1arPrXikDtVbvn5ol3MFJpu8?= =?us-ascii?Q?kD1G/BurWT9WMPuBe+6eCkbVHn7/gi67jF3Ak9eCxwMhUE8MVpGJLkPQhCJx?= =?us-ascii?Q?lHYA76a7Yl5wZwVgiMI/VZaNAbjI8QEs7EbWtN7/ywWUV0kRd8CSyn7A0BJT?= =?us-ascii?Q?/kb5/7lJsDyU/KbS0p6CFgORiCZrwIGSpUTizmBi4fvCVfn4TD/wTGP9GkVe?= =?us-ascii?Q?WGoHj3hxob6odm8dwWuJmIwowxBdznpX16XM0Z2vx3x1q0OPzc7CEsuk4RDP?= =?us-ascii?Q?vvbfitW/3v5pwxT/ma8iITftSDzQN2f3FK7UdMO+PVoAJZBYPzYDPt+Fvxv2?= =?us-ascii?Q?1mWdl5XbUmkTNPBfayr4heE+FzNLB4OgTrJb1acqjx+oiO2TN3ZoAtWxyXp6?= =?us-ascii?Q?gG+f3h8keNrK442Dz978wnA3dc61kiTpganm2/1kE9wANG5VmYmVJ6vgf5eU?= =?us-ascii?Q?LBb9K0Zb0B2R9OpYvwZhM5pukp/mh9uGXv6h/3T0FHOGAL4HlozYw98NH4ks?= =?us-ascii?Q?MJJnMHbgQYQd3WRhwoZzI4BVqnygTgbMzlr58L3dlT3/ur7IFrkWMorqL3VN?= =?us-ascii?Q?PAVyCL9py3vyqFQIJEbU42PSHyHaex5Yv12x3B2869Odh/2GbUMMyyBhhWcB?= =?us-ascii?Q?/m9DEIH129rOgDNFdfzYQGB6V9D8KdzfJf4OnYKe7JnnUlR/XvS7XZHEaXza?= =?us-ascii?Q?/3bKUi4YGDWrLXDnro+M/n+RrDeuzcr+bkUyKX9zRjoWZCiPsiBRroycNrOz?= =?us-ascii?Q?npLx+FQOcdCtJNqgL4x4ZPrflRPqQgXwek8k+gvkwxWtXiCU7wPtfWZa/6Q2?= =?us-ascii?Q?xgM1m/199Af+J2BXOrRFrJ/eRJTyA3FTpQm/1nJE6N1Q/G5UqC7fvPr4vVhM?= =?us-ascii?Q?xPO8uDcjr055j+hWNPen2OupBslAHz1GanJEU+w7VhZHo/ZocJfUAF70U2GK?= =?us-ascii?Q?laI6lGI8lUw+l6iLDzOZP1FG2P7esmYD794tJJpYI6QXwKa5U4ijdhvLki5M?= =?us-ascii?Q?UxOixmOW4PtXs4IC/N7rf6Kl0b9jZTscETYxW8PpMGjQqIAHtgfVCBBxlaIE?= =?us-ascii?Q?l9i+eq+Z14SVXpkc3tAAxqnwlFYKNeM8AD+ARgCZo1Q9bIQwZWep36DXOXau?= =?us-ascii?Q?9qbjHzzfg16ymJMNCV76uU+Nsk4WMYB0C6vthjq/mXgbsRkM8Blq6YWP58u3?= =?us-ascii?Q?5rPTigGa/E2PU7hwCcz4udU1aVF3ITvq7tSE4ohwjmeroVMxzGTPWYF7On4K?= =?us-ascii?Q?r8FwTwfDuZ99Hbsy6sSfi/MvGLezH4H0Ntevx1cZgKNRsFwZZpolYpX3hO6+?= =?us-ascii?Q?bASOSeP5WU0P9cBkB1bFI/jWevPjcYlJLgXX3kajnYkABJj6oV8BxufHOYyO?= =?us-ascii?Q?dRWH37dQGLepdILhQdqthTGt1yIiOOtcuowjb4OmpNDa9hVbrDeM4VJLx3m1?= =?us-ascii?Q?1Kzwx5MQD6Uym8Fs4k2sMTCbB1dLTJdw7TJPZpcMgOx0M/QGQ/1zG9XzUIw/?= =?us-ascii?Q?SgwgeWfb7+LZxpCENTk=3D?= MIME-Version: 1.0 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: CH2PR12MB3957.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: ea3363d0-1b86-451d-684a-08db54ffb014 X-MS-Exchange-CrossTenant-originalarrivaltime: 15 May 2023 04:48:54.9980 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: lBs0NxwReO0q0sM/ISJwwJf76+iPSLGleh5irVaquSRoW3x5RNsLf1I2ZBD24OawoKVP51oycrY7PCjYI29LPw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR12MB7001 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable [AMD Official Use Only - General] Reviewed-by: Abner Chang > -----Original Message----- > From: Nickle Wang > Sent: Monday, May 15, 2023 12:25 PM > To: devel@edk2.groups.io > Cc: Chang, Abner ; Igor Kulchytskyy > > Subject: [PATCH] RedfishPkg/RedfishPlatformConfigDxe: Fix string assert > issue >=20 > Caution: This message originated from an External Source. Use proper > caution when opening attachments, clicking links, or responding. >=20 >=20 > 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 >=20 > 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(-) >=20 > 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 >=20 > +/** > + 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 > ); >=20 > +/** > + 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. = The > returned string is allocated using AllocatePool(). The caller is resp= onsible > 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; >=20 > 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'; >=20 > switch (HiiStatement->Operand) { > case EFI_IFR_ONE_OF_OP: > @@ -1205,9 +1207,18 @@ HiiValueToRedfishValue ( > break; > } >=20 > - RedfishValue->Type =3D RedfishValueTypeString; > - RedfishValue->Value.Buffer =3D AllocatePool (StrLen ((CHAR16 *)Val= ue- > >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 (NullCha= r), > &NullChar); > + } else { > + RedfishValue->Value.Buffer =3D StrToAsciiStr ((EFI_STRING)Value- > >Buffer); > + } > + > + 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 ( >=20 > 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 Englis= h. > + // > + RedfishValue->Value.Buffer =3D HiiGetEnglishAsciiString (HiiHand= le, > 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 > contact 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; >=20 > - if ((AsciiString =3D=3D NULL) || (AsciiString[0] =3D=3D '\0')) { > + if (AsciiString =3D=3D NULL) { > return NULL; > } >=20 > @@ -1303,6 +1338,43 @@ StrToUnicodeStr ( > return Buffer; > } >=20 > +/** > + 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 Versio= n. >=20 > @@ -1641,6 +1713,17 @@ RedfishPlatformConfigSetStatementCommon ( > } > } >=20 > + 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- > >ParentForm->ParentFormset->HiiHandle, 0x00, > (EFI_STRING)StatementValue->Buffer, NULL); > + 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; > } >=20 > - return EFI_SUCCESS; > + if (StatementValue->Value.string !=3D 0) { > + HiiDeleteString (StatementValue->Value.string, TargetStatement- > >ParentForm->ParentFormset->HiiHandle); > + } > + > + return Status; > } >=20 > /** > @@ -1712,9 +1798,14 @@ RedfishPlatformConfigProtocolSetValue ( >=20 > 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.Value.Buffer); > + NewValue.BufferLen =3D (UINT16)(AsciiStrSize (Value.Value.Buffer) = * > sizeof (CHAR16)); > + NewValue.Buffer =3D (UINT8 *)StrToUnicodeStr (Value.Value.Buffe= r); > if (NewValue.Buffer =3D=3D NULL) { > Status =3D EFI_OUT_OF_RESOURCES; > goto RELEASE_RESOURCE; > @@ -1742,6 +1833,10 @@ RELEASE_RESOURCE: > FreePool (FullSchema); > } >=20 > + if ((Value.Type =3D=3D RedfishValueTypeString) && (NewValue.Buffer != =3D > NULL)) { > + FreePool (NewValue.Buffer); > + } > + > return Status; > } >=20 > @@ -1784,6 +1879,7 @@ RedfishPlatformConfigProtocolGetConfigureLang ( > return EFI_INVALID_PARAMETER; > } >=20 > + ZeroMem (&StatementList, sizeof (StatementList)); > *Count =3D 0; > *ConfigureLangList =3D NULL; > FullSchema =3D NULL; > @@ -1849,7 +1945,9 @@ RELEASE_RESOURCE: > FreePool (FullSchema); > } >=20 > - ReleaseStatementList (&StatementList); > + if (StatementList.Count > 0) { > + ReleaseStatementList (&StatementList); > + } >=20 > 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; > } >=20 > +/** > + 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. = The > returned string is allocated using AllocatePool(). The caller is resp= onsible > @@ -259,7 +287,6 @@ HiiGetRedfishAsciiString ( > ) > { > EFI_STRING HiiString; > - UINTN StringSize; > CHAR8 *AsciiString; >=20 > HiiString =3D HiiGetRedfishString (HiiHandle, Language, StringId); > @@ -268,15 +295,9 @@ HiiGetRedfishAsciiString ( > return NULL; > } >=20 > - 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; > } >=20 > @@ -322,7 +343,6 @@ HiiGetEnglishAsciiString ( > ) > { > EFI_STRING HiiString; > - UINTN StringSize; > CHAR8 *AsciiString; >=20 > HiiString =3D HiiGetRedfishString (HiiHandle, ENGLISH_LANGUAGE_CODE, > StringId); > @@ -331,15 +351,9 @@ HiiGetEnglishAsciiString ( > return NULL; > } >=20 > - 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; > } >=20 > -- > 2.17.1