From 9fe4bcfe7934f44be55264af9fd8523936f5bd40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filip=20Go=C5=82a=C5=9B?= Date: Thu, 1 Aug 2024 10:31:04 +0200 Subject: [PATCH] SecureBootConfigImpl.c: Try using AsciiStrToUnicodeStrS again MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Filip Gołaś --- .../SecureBootConfigImpl.c | 39 +++++++++---------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfigImpl.c b/SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfigImpl.c index 209fdbff64..c819a98a6f 100644 --- a/SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfigImpl.c +++ b/SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfigImpl.c @@ -2541,18 +2541,18 @@ UpdateDeletePage ( EFI_SIGNATURE_DATA *Cert; UINT32 ItemDataSize; CHAR16 *CertificateInfoStr; - EFI_STRING_ID GuidID; + CHAR8 *CertificateInfoStr8; + EFI_STRING_ID CertificateInfoID; EFI_STRING_ID Help; UINTN CertificateInfoStrSize = 100; UINTN CertificateInfoStrLen; - CHAR8* CertificateInfoStrIterator8; - CHAR16* CertificateInfoStrIterator16; - const CHAR16* UNKNOWN_CERT = L"Unknown Certificate: No Common Name, No Issuer"; + CHAR16* UNKNOWN_CERT = L"Unknown Certificate: No Common Name, No Issuer"; Data = NULL; CertList = NULL; Cert = NULL; CertificateInfoStr = NULL; + CertificateInfoStr8 = NULL; StartOpCodeHandle = NULL; EndOpCodeHandle = NULL; @@ -2612,6 +2612,11 @@ UpdateDeletePage ( goto ON_EXIT; } + CertificateInfoStr8 = AllocateZeroPool (CertificateInfoStrSize * sizeof(CHAR8)); + if (CertificateInfoStr8 == NULL) { + Status = EFI_OUT_OF_RESOURCES; + goto ON_EXIT; + } CertificateInfoStr = AllocateZeroPool (CertificateInfoStrSize * sizeof(CHAR16)); if (CertificateInfoStr == NULL) { Status = EFI_OUT_OF_RESOURCES; @@ -2664,33 +2669,23 @@ UpdateDeletePage ( X509GetCommonName ( (UINT8*)Cert->SignatureData, (UINTN)CertList->SignatureSize, - (CHAR8*) CertificateInfoStr, + CertificateInfoStr8, &CertificateInfoStrLen ) ) { - CertificateInfoStrIterator8 = ((CHAR8*)CertificateInfoStr) + CertificateInfoStrLen; - CertificateInfoStrIterator16 = CertificateInfoStr + CertificateInfoStrLen; - int i = 0; - for (; i < CertificateInfoStrSize; i++) - { - CertificateInfoStrIterator16[CertificateInfoStrLen-i] = CertificateInfoStrIterator8[CertificateInfoStrLen-i]; - if(CertificateInfoStrIterator8[CertificateInfoStrLen-i] == '\0') break; - } - - if (i < 2) - { - StrCatS (CertificateInfoStr, CertificateInfoStrSize, UNKNOWN_CERT); - } + AsciiStrToUnicodeStrS (CertificateInfoStr8, CertificateInfoStr, CertificateInfoStrSize); + CertificateInfoID = HiiSetString (PrivateData->HiiHandle, 0, CertificateInfoStr, NULL); + } else { + CertificateInfoID = HiiSetString (PrivateData->HiiHandle, 0, UNKNOWN_CERT, NULL); } - GuidID = HiiSetString (PrivateData->HiiHandle, 0, CertificateInfoStr, NULL); HiiCreateCheckBoxOpCode ( StartOpCodeHandle, (EFI_QUESTION_ID)(QuestionIdBase + GuidIndex++), 0, 0, - GuidID, + CertificateInfoID, Help, EFI_IFR_FLAG_CALLBACK | EFI_IFR_FLAG_RESET_REQUIRED, 0, @@ -2727,6 +2722,10 @@ UpdateDeletePage ( FreePool (CertificateInfoStr); } + if (CertificateInfoStr8 != NULL) { + FreePool (CertificateInfoStr8); + } + return EFI_SUCCESS; }