From nobody Wed Dec 25 14:21:41 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1507601307829734.0844770587426; Mon, 9 Oct 2017 19:08:27 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 9EACE2095B071; Mon, 9 Oct 2017 19:04:58 -0700 (PDT) Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 5A4BA20945BD7 for ; Mon, 9 Oct 2017 19:04:57 -0700 (PDT) Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga104.jf.intel.com with ESMTP; 09 Oct 2017 19:08:24 -0700 Received: from chenche4.ccr.corp.intel.com ([10.239.158.36]) by fmsmga004.fm.intel.com with ESMTP; 09 Oct 2017 19:08:23 -0700 X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.31; helo=mga06.intel.com; envelope-from=chen.a.chen@intel.com; receiver=edk2-devel@lists.01.org X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.42,502,1500966000"; d="scan'208";a="321392410" From: chenc2 To: edk2-devel@lists.01.org Date: Tue, 10 Oct 2017 10:08:07 +0800 Message-Id: <20171010020807.16452-1-chen.a.chen@intel.com> X-Mailer: git-send-email 2.13.2.windows.1 Subject: [edk2] [PATCH] SecurityPkg/SecureBootConfigImpl.c: Fix the potential NULL dereference. X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Wu Hao , Zhang Chao MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Cc: Zhang Chao Cc: Wu Hao Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Chen A Chen --- .../SecureBootConfigDxe/SecureBootConfigImpl.c | 80 +++++++++++++++---= ---- 1 file changed, 57 insertions(+), 23 deletions(-) diff --git a/SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBo= otConfigImpl.c b/SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/Secu= reBootConfigImpl.c index 3e03be9738..457e020ece 100644 --- a/SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfi= gImpl.c +++ b/SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfi= gImpl.c @@ -3579,7 +3579,9 @@ LoadSignatureList ( ) { EFI_STATUS Status; - EFI_STRING_ID ListType; + EFI_STRING EfiStringTemp1; + EFI_STRING EfiStringTemp2; + EFI_STRING_ID ListType;; EFI_SIGNATURE_LIST *ListWalker; EFI_IFR_GUID_LABEL *StartLabel; EFI_IFR_GUID_LABEL *EndLabel; @@ -3599,6 +3601,8 @@ LoadSignatureList ( CHAR16 *HelpBuffer; =20 Status =3D EFI_SUCCESS; + EfiStringTemp1 =3D NULL; + EfiStringTemp2 =3D NULL; StartOpCodeHandle =3D NULL; EndOpCodeHandle =3D NULL; StartGotoHandle =3D NULL; @@ -3755,17 +3759,19 @@ LoadSignatureList ( ListType =3D STRING_TOKEN (STR_LIST_TYPE_UNKNOWN); } =20 - UnicodeSPrint (NameBuffer, - 100, - HiiGetString (PrivateData->HiiHandle, STRING_TOKEN (STR_SIGNATURE_LI= ST_NAME_FORMAT), NULL), - Index + 1 - ); - UnicodeSPrint (HelpBuffer, - 100, - HiiGetString (PrivateData->HiiHandle, STRING_TOKEN (STR_SIGNATURE_LI= ST_HELP_FORMAT), NULL), - HiiGetString (PrivateData->HiiHandle, ListType, NULL), - SIGNATURE_DATA_COUNTS (ListWalker) - ); + EfiStringTemp1 =3D HiiGetString (PrivateData->HiiHandle, STRING_TOKEN = (STR_SIGNATURE_LIST_NAME_FORMAT), NULL); + if (EfiStringTemp1 =3D=3D NULL) { + goto ON_EXIT; + } + UnicodeSPrint (NameBuffer, 100, EfiStringTemp1, Index + 1); + EfiStringTemp1 =3D NULL; + + EfiStringTemp1 =3D HiiGetString (PrivateData->HiiHandle, STRING_TOKEN = (STR_SIGNATURE_LIST_HELP_FORMAT), NULL); + EfiStringTemp2 =3D HiiGetString (PrivateData->HiiHandle, ListType, NUL= L); + if (EfiStringTemp1 =3D=3D NULL || EfiStringTemp2 =3D=3D NULL) { + goto ON_EXIT; + } + UnicodeSPrint (HelpBuffer, 100, EfiStringTemp1, EfiStringTemp2, SIGNAT= URE_DATA_COUNTS (ListWalker)); =20 HiiCreateGotoOpCode ( StartOpCodeHandle, @@ -3953,6 +3959,8 @@ FormatHelpInfo ( { EFI_STATUS Status; EFI_TIME *Time; + EFI_STRING EfiStringTemp1; + EFI_STRING EfiStringTemp2; EFI_STRING_ID ListTypeId; UINTN DataSize; UINTN HelpInfoIndex; @@ -3964,6 +3972,8 @@ FormatHelpInfo ( BOOLEAN IsCert; =20 Status =3D EFI_SUCCESS; + EfiStringTemp1 =3D NULL; + EfiStringTemp2 =3D NULL; Time =3D NULL; HelpInfoIndex =3D 0; GuidString =3D NULL; @@ -4016,6 +4026,10 @@ FormatHelpInfo ( goto ON_EXIT; } =20 + EfiStringTemp1 =3D HiiGetString (PrivateData->HiiHandle, STRING_TOKEN (S= TR_SIGNATURE_DATA_HELP_FORMAT_GUID), NULL); + if (EfiStringTemp1 =3D=3D NULL) { + goto ON_EXIT; + } // // Format GUID part. // @@ -4023,20 +4037,29 @@ FormatHelpInfo ( HelpInfoIndex +=3D UnicodeSPrint ( &HelpInfoString[HelpInfoIndex], TotalSize - sizeof(CHAR16) * HelpInfoIndex, - HiiGetString (PrivateData->HiiHandle, STRING_TOKEN (S= TR_SIGNATURE_DATA_HELP_FORMAT_GUID), NULL), + EfiStringTemp1, GuidString ); + EfiStringTemp1 =3D NULL; =20 + EfiStringTemp2 =3D HiiGetString (PrivateData->HiiHandle, ListTypeId, NUL= L); + if (EfiStringTemp2 =3D=3D NULL) { + goto ON_EXIT; + } // // Format content part, it depends on the type of signature list, hash v= alue or CN. // if (IsCert) { GetCommonNameFromX509 (ListEntry, DataEntry, &DataString); + EfiStringTemp1 =3D HiiGetString (PrivateData->HiiHandle, STRING_TOKEN = (STR_SIGNATURE_DATA_HELP_FORMAT_CN), NULL); + if (EfiStringTemp1 =3D=3D NULL) { + goto ON_EXIT; + } HelpInfoIndex +=3D UnicodeSPrint( &HelpInfoString[HelpInfoIndex], TotalSize - sizeof(CHAR16) * HelpInfoIndex, - HiiGetString (PrivateData->HiiHandle, STRING_TOKEN = (STR_SIGNATURE_DATA_HELP_FORMAT_CN), NULL), - HiiGetString (PrivateData->HiiHandle, ListTypeId, N= ULL), + EfiStringTemp1, + EfiStringTemp2, DataSize, DataString ); @@ -4045,15 +4068,20 @@ FormatHelpInfo ( // Format hash value for each signature data entry. // ParseHashValue (ListEntry, DataEntry, &DataString); + EfiStringTemp1 =3D HiiGetString (PrivateData->HiiHandle, STRING_TOKEN = (STR_SIGNATURE_DATA_HELP_FORMAT_HASH), NULL); + if (EfiStringTemp1 =3D=3D NULL) { + goto ON_EXIT; + } HelpInfoIndex +=3D UnicodeSPrint ( &HelpInfoString[HelpInfoIndex], TotalSize - sizeof(CHAR16) * HelpInfoIndex, - HiiGetString (PrivateData->HiiHandle, STRING_TOKEN = (STR_SIGNATURE_DATA_HELP_FORMAT_HASH), NULL), - HiiGetString (PrivateData->HiiHandle, ListTypeId, N= ULL), + EfiStringTemp1, + EfiStringTemp2, DataSize, DataString ); } + EfiStringTemp1 =3D NULL; =20 // // Format revocation time part. @@ -4077,10 +4105,14 @@ FormatHelpInfo ( Time->Second ); =20 + EfiStringTemp1 =3D HiiGetString (PrivateData->HiiHandle, STRING_TOKEN = (STR_SIGNATURE_DATA_HELP_FORMAT_TIME), NULL); + if (EfiStringTemp1 =3D=3D NULL) { + goto ON_EXIT; + } UnicodeSPrint ( &HelpInfoString[HelpInfoIndex], TotalSize - sizeof (CHAR16) * HelpInfoIndex, - HiiGetString (PrivateData->HiiHandle, STRING_TOKEN (STR_SIGNATURE_DA= TA_HELP_FORMAT_TIME), NULL), + EfiStringTemp1, TimeString ); } @@ -4122,6 +4154,7 @@ LoadSignatureData ( EFI_SIGNATURE_DATA *DataWalker; EFI_IFR_GUID_LABEL *StartLabel; EFI_IFR_GUID_LABEL *EndLabel; + EFI_STRING EfiString; EFI_STRING_ID HelpStringId; VOID *StartOpCodeHandle; VOID *EndOpCodeHandle; @@ -4133,6 +4166,7 @@ LoadSignatureData ( CHAR16 *NameBuffer; =20 Status =3D EFI_SUCCESS; + EfiString =3D NULL; StartOpCodeHandle =3D NULL; EndOpCodeHandle =3D NULL; Index =3D 0; @@ -4229,15 +4263,15 @@ LoadSignatureData ( } =20 DataWalker =3D (EFI_SIGNATURE_DATA *)((UINT8 *)ListWalker + sizeof(EFI_S= IGNATURE_LIST) + ListWalker->SignatureHeaderSize); + EfiString =3D HiiGetString (PrivateData->HiiHandle, STRING_TOKEN (STR_SI= GNATURE_DATA_NAME_FORMAT), NULL); + if (EfiString =3D=3D NULL) { + goto ON_EXIT; + } for (Index =3D 0; Index < SIGNATURE_DATA_COUNTS(ListWalker); Index =3D I= ndex + 1) { // // Format name buffer. // - UnicodeSPrint (NameBuffer, - 100, - HiiGetString (PrivateData->HiiHandle, STRING_TOKEN (STR_SIGNATURE_DA= TA_NAME_FORMAT), NULL), - Index + 1 - ); + UnicodeSPrint (NameBuffer, 100, EfiString, Index + 1); =20 // // Format help info buffer. --=20 2.13.2.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel