SecurityPkg OpalPasswordDxe: Clean PSID buffer.

Change callback handler type to avoid saving PSID info in
browser temp buffer. Also clean the buffer after using it.

Cc: Feng Tian <feng.tian@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Eric Dong <eric.dong@intel.com>
This commit is contained in:
Eric Dong 2016-11-21 14:38:31 +08:00 committed by Star Zeng
parent bee13c0021
commit 01dd077315
2 changed files with 17 additions and 10 deletions

View File

@ -501,14 +501,13 @@ DriverCallback(
case HII_KEY_ID_ENTER_PASSWORD: case HII_KEY_ID_ENTER_PASSWORD:
return HiiPasswordEntered(Value->string); return HiiPasswordEntered(Value->string);
case HII_KEY_ID_ENTER_PSID:
return HiiPsidRevert(Value->string);
} }
} else if (Action == EFI_BROWSER_ACTION_CHANGED) { } else if (Action == EFI_BROWSER_ACTION_CHANGED) {
switch (HiiKeyId) { switch (HiiKeyId) {
case HII_KEY_ID_ENTER_PSID:
HiiPsidRevert();
*ActionRequest = EFI_BROWSER_ACTION_REQUEST_FORM_APPLY;
return EFI_SUCCESS;
case HII_KEY_ID_BLOCKSID: case HII_KEY_ID_BLOCKSID:
switch (Value->u8) { switch (Value->u8) {
case 0: case 0:
@ -661,12 +660,14 @@ HiiPopulateDiskInfoForm(
/** /**
Reverts the Opal disk to factory default. Reverts the Opal disk to factory default.
@param PsidStringId The string id for the PSID info.
@retval EFI_SUCCESS Do the required action success. @retval EFI_SUCCESS Do the required action success.
**/ **/
EFI_STATUS EFI_STATUS
HiiPsidRevert( HiiPsidRevert(
VOID EFI_STRING_ID PsidStringId
) )
{ {
CHAR8 Response[DEFAULT_RESPONSE_SIZE]; CHAR8 Response[DEFAULT_RESPONSE_SIZE];
@ -674,15 +675,19 @@ HiiPsidRevert(
OPAL_DISK *OpalDisk; OPAL_DISK *OpalDisk;
TCG_RESULT Ret; TCG_RESULT Ret;
OPAL_SESSION Session; OPAL_SESSION Session;
CHAR16 *UnicodeStr;
UINT8 TmpBuf[PSID_CHARACTER_STRING_END_LENGTH]; UINT8 TmpBuf[PSID_CHARACTER_STRING_END_LENGTH];
Ret = TcgResultFailure; Ret = TcgResultFailure;
OpalHiiGetBrowserData(); UnicodeStr = HiiGetString (gHiiPackageListHandle, PsidStringId, NULL);
ZeroMem (TmpBuf, sizeof (TmpBuf)); 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); 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); OpalDisk = HiiGetOpalDiskCB (gHiiConfiguration.SelectedDiskIndex);
if (OpalDisk != NULL) { if (OpalDisk != NULL) {

View File

@ -225,12 +225,14 @@ HiiSetBlockSidAction (
/** /**
Reverts the Opal disk to factory default. Reverts the Opal disk to factory default.
@param PsidStringId The string id for the PSID info.
@retval EFI_SUCCESS Do the required action success. @retval EFI_SUCCESS Do the required action success.
**/ **/
EFI_STATUS EFI_STATUS
HiiPsidRevert( HiiPsidRevert(
VOID EFI_STRING_ID PsidStringId
); );
/** /**