From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) (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 2673481EFE for ; Tue, 15 Nov 2016 22:16:03 -0800 (PST) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga105.fm.intel.com with ESMTP; 15 Nov 2016 22:16:08 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.31,646,1473145200"; d="scan'208";a="1085868079" Received: from shwde7156.ccr.corp.intel.com ([10.239.158.52]) by fmsmga002.fm.intel.com with ESMTP; 15 Nov 2016 22:16:06 -0800 From: Eric Dong To: edk2-devel@lists.01.org Cc: Feng Tian , Jiewen Yao Date: Wed, 16 Nov 2016 14:15:30 +0800 Message-Id: <1479276930-31360-3-git-send-email-eric.dong@intel.com> X-Mailer: git-send-email 2.6.4.windows.1 In-Reply-To: <1479276930-31360-1-git-send-email-eric.dong@intel.com> References: <1479276930-31360-1-git-send-email-eric.dong@intel.com> Subject: [Patch 2/2] SecurityPkg OpalPasswordDxe: Clean PSID buffer. X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 16 Nov 2016 06:16:03 -0000 Change callback handler type to avoid saving PSID info in browser temp buffer. Also clean the buffer after using it. Cc: Feng Tian Cc: Jiewen Yao Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Eric Dong --- SecurityPkg/Tcg/Opal/OpalPasswordDxe/OpalHii.c | 23 +++++++++++++--------- .../Tcg/Opal/OpalPasswordDxe/OpalHiiPrivate.h | 4 +++- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/SecurityPkg/Tcg/Opal/OpalPasswordDxe/OpalHii.c b/SecurityPkg/Tcg/Opal/OpalPasswordDxe/OpalHii.c index 5937ce2..7371b7e 100644 --- a/SecurityPkg/Tcg/Opal/OpalPasswordDxe/OpalHii.c +++ b/SecurityPkg/Tcg/Opal/OpalPasswordDxe/OpalHii.c @@ -501,14 +501,13 @@ DriverCallback( case HII_KEY_ID_ENTER_PASSWORD: return HiiPasswordEntered(Value->string); + + case HII_KEY_ID_ENTER_PSID: + return HiiPsidRevert(Value->string); + } } else if (Action == EFI_BROWSER_ACTION_CHANGED) { switch (HiiKeyId) { - case HII_KEY_ID_ENTER_PSID: - HiiPsidRevert(); - *ActionRequest = EFI_BROWSER_ACTION_REQUEST_FORM_APPLY; - return EFI_SUCCESS; - case HII_KEY_ID_BLOCKSID: switch (Value->u8) { case 0: @@ -661,12 +660,14 @@ HiiPopulateDiskInfoForm( /** Reverts the Opal disk to factory default. + @param PsidStringId The string id for the PSID info. + @retval EFI_SUCCESS Do the required action success. **/ EFI_STATUS HiiPsidRevert( - VOID + EFI_STRING_ID PsidStringId ) { CHAR8 Response[DEFAULT_RESPONSE_SIZE]; @@ -674,15 +675,19 @@ HiiPsidRevert( OPAL_DISK *OpalDisk; TCG_RESULT Ret; OPAL_SESSION Session; + CHAR16 *UnicodeStr; UINT8 TmpBuf[PSID_CHARACTER_STRING_END_LENGTH]; Ret = TcgResultFailure; - OpalHiiGetBrowserData(); - + UnicodeStr = HiiGetString (gHiiPackageListHandle, PsidStringId, NULL); ZeroMem (TmpBuf, sizeof (TmpBuf)); - UnicodeStrToAsciiStrS (gHiiConfiguration.Psid, (CHAR8*)TmpBuf, PSID_CHARACTER_STRING_END_LENGTH); + UnicodeStrToAsciiStrS (UnicodeStr, (CHAR8*)TmpBuf, PSID_CHARACTER_STRING_END_LENGTH); CopyMem (Psid.Psid, TmpBuf, PSID_CHARACTER_LENGTH); + HiiSetString (gHiiPackageListHandle, PsidStringId, L"", NULL); + ZeroMem (TmpBuf, sizeof (TmpBuf)); + ZeroMem (UnicodeStr, StrSize (UnicodeStr)); + FreePool (UnicodeStr); OpalDisk = HiiGetOpalDiskCB (gHiiConfiguration.SelectedDiskIndex); if (OpalDisk != NULL) { diff --git a/SecurityPkg/Tcg/Opal/OpalPasswordDxe/OpalHiiPrivate.h b/SecurityPkg/Tcg/Opal/OpalPasswordDxe/OpalHiiPrivate.h index a7709dd..ec5a93c 100644 --- a/SecurityPkg/Tcg/Opal/OpalPasswordDxe/OpalHiiPrivate.h +++ b/SecurityPkg/Tcg/Opal/OpalPasswordDxe/OpalHiiPrivate.h @@ -225,12 +225,14 @@ HiiSetBlockSidAction ( /** Reverts the Opal disk to factory default. + @param PsidStringId The string id for the PSID info. + @retval EFI_SUCCESS Do the required action success. **/ EFI_STATUS HiiPsidRevert( - VOID + EFI_STRING_ID PsidStringId ); /** -- 2.6.4.windows.1