SecurityPkg OpalPasswordDxe: Clean password buffer.
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:
		@@ -240,6 +240,7 @@ OpalDriverPopUpHddPassword (
 | 
				
			|||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  UnicodeStrToAsciiStrS (Unicode, Ascii, MAX_PASSWORD_SIZE + 1);
 | 
					  UnicodeStrToAsciiStrS (Unicode, Ascii, MAX_PASSWORD_SIZE + 1);
 | 
				
			||||||
 | 
					  ZeroMem (Unicode, sizeof (Unicode));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  return Ascii;
 | 
					  return Ascii;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -694,6 +694,8 @@ HiiPsidRevert(
 | 
				
			|||||||
    Ret = OpalSupportPsidRevert(&Session, Psid.Psid, (UINT32)sizeof(Psid.Psid), OpalDisk->OpalDevicePath);
 | 
					    Ret = OpalSupportPsidRevert(&Session, Psid.Psid, (UINT32)sizeof(Psid.Psid), OpalDisk->OpalDevicePath);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  ZeroMem (Psid.Psid, PSID_CHARACTER_LENGTH);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (Ret == TcgResultSuccess) {
 | 
					  if (Ret == TcgResultSuccess) {
 | 
				
			||||||
    AsciiSPrint( Response, DEFAULT_RESPONSE_SIZE, "%a", "PSID Revert: Success" );
 | 
					    AsciiSPrint( Response, DEFAULT_RESPONSE_SIZE, "%a", "PSID Revert: Success" );
 | 
				
			||||||
  } else {
 | 
					  } else {
 | 
				
			||||||
@@ -1099,8 +1101,8 @@ HiiPasswordEntered(
 | 
				
			|||||||
  EFI_STRING_ID            Str
 | 
					  EFI_STRING_ID            Str
 | 
				
			||||||
  )
 | 
					  )
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  OPAL_DISK*                    OpalDisk;
 | 
					  OPAL_DISK*                   OpalDisk;
 | 
				
			||||||
  CHAR8                         Password[MAX_PASSWORD_CHARACTER_LENGTH + 1];
 | 
					  CHAR8                        Password[MAX_PASSWORD_CHARACTER_LENGTH + 1];
 | 
				
			||||||
  CHAR16*                      UniStr;
 | 
					  CHAR16*                      UniStr;
 | 
				
			||||||
  UINT32                       PassLength;
 | 
					  UINT32                       PassLength;
 | 
				
			||||||
  EFI_STATUS                   Status;
 | 
					  EFI_STATUS                   Status;
 | 
				
			||||||
@@ -1124,15 +1126,20 @@ HiiPasswordEntered(
 | 
				
			|||||||
  if (UniStr == NULL) {
 | 
					  if (UniStr == NULL) {
 | 
				
			||||||
    return EFI_NOT_FOUND;
 | 
					    return EFI_NOT_FOUND;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  HiiSetString(gHiiPackageListHandle, Str, L"", NULL);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  PassLength = (UINT32) StrLen (UniStr);
 | 
					  PassLength = (UINT32) StrLen (UniStr);
 | 
				
			||||||
  if (PassLength >= sizeof(Password)) {
 | 
					  if (PassLength >= sizeof(Password)) {
 | 
				
			||||||
    HiiSetFormString(STRING_TOKEN(STR_ACTION_STATUS), "Password too long");
 | 
					    HiiSetFormString(STRING_TOKEN(STR_ACTION_STATUS), "Password too long");
 | 
				
			||||||
    gBS->FreePool(UniStr);
 | 
					    ZeroMem (UniStr, StrSize (UniStr));
 | 
				
			||||||
 | 
					    FreePool(UniStr);
 | 
				
			||||||
    return EFI_BUFFER_TOO_SMALL;
 | 
					    return EFI_BUFFER_TOO_SMALL;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  UnicodeStrToAsciiStrS (UniStr, Password, sizeof (Password));
 | 
					  UnicodeStrToAsciiStrS (UniStr, Password, sizeof (Password));
 | 
				
			||||||
  gBS->FreePool(UniStr);
 | 
					  ZeroMem (UniStr, StrSize (UniStr));
 | 
				
			||||||
 | 
					  FreePool(UniStr);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (gHiiConfiguration.SelectedAction == HII_KEY_ID_GOTO_UNLOCK) {
 | 
					  if (gHiiConfiguration.SelectedAction == HII_KEY_ID_GOTO_UNLOCK) {
 | 
				
			||||||
    Status = HiiUnlock (OpalDisk, Password, PassLength);
 | 
					    Status = HiiUnlock (OpalDisk, Password, PassLength);
 | 
				
			||||||
@@ -1154,6 +1161,8 @@ HiiPasswordEntered(
 | 
				
			|||||||
    Status = HiiSetPassword(OpalDisk, Password, PassLength);
 | 
					    Status = HiiSetPassword(OpalDisk, Password, PassLength);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  ZeroMem (Password, sizeof (Password));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  OpalHiiSetBrowserData ();
 | 
					  OpalHiiSetBrowserData ();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  return Status;
 | 
					  return Status;
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user