mirror of https://github.com/acidanthera/audk.git
Add error handling code to prevent variable store corruption in release build.
Signed-off-by: Fu Siyuan <siyuan.fu@intel.com> Reviewed-by: Ye Ting <ting.ye@intel.com> Reviewed-by: Dong Guo <guo.dong@intel.com> git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@14139 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
fb5278ef78
commit
ca5a7d87e3
|
@ -445,6 +445,10 @@ AddPubKeyInStore (
|
||||||
FALSE
|
FALSE
|
||||||
);
|
);
|
||||||
ASSERT_EFI_ERROR (Status);
|
ASSERT_EFI_ERROR (Status);
|
||||||
|
if (EFI_ERROR (Status)) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Check whether the public key entry does exist.
|
// Check whether the public key entry does exist.
|
||||||
//
|
//
|
||||||
|
@ -492,6 +496,9 @@ AddPubKeyInStore (
|
||||||
FALSE
|
FALSE
|
||||||
);
|
);
|
||||||
ASSERT_EFI_ERROR (Status);
|
ASSERT_EFI_ERROR (Status);
|
||||||
|
if (EFI_ERROR (Status)) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
DataSize = DataSizeOfVariable (Variable.CurrPtr);
|
DataSize = DataSizeOfVariable (Variable.CurrPtr);
|
||||||
Data = GetVariableDataPtr (Variable.CurrPtr);
|
Data = GetVariableDataPtr (Variable.CurrPtr);
|
||||||
|
|
|
@ -659,8 +659,9 @@ PubKeyStoreFilter (
|
||||||
@param[in] ReclaimPubKeyStore Reclaim for public key database or not.
|
@param[in] ReclaimPubKeyStore Reclaim for public key database or not.
|
||||||
@param[in] ReclaimAnyway If TRUE, do reclaim anyway.
|
@param[in] ReclaimAnyway If TRUE, do reclaim anyway.
|
||||||
|
|
||||||
@return EFI_OUT_OF_RESOURCES No enough memory resources.
|
|
||||||
@return EFI_SUCCESS Reclaim operation has finished successfully.
|
@return EFI_SUCCESS Reclaim operation has finished successfully.
|
||||||
|
@return EFI_OUT_OF_RESOURCES No enough memory resources.
|
||||||
|
@return EFI_DEVICE_ERROR The public key database doesn't exist.
|
||||||
@return Others Unexpect error happened during reclaim operation.
|
@return Others Unexpect error happened during reclaim operation.
|
||||||
|
|
||||||
**/
|
**/
|
||||||
|
@ -809,6 +810,12 @@ Reclaim (
|
||||||
// Reinstall the new public key database.
|
// Reinstall the new public key database.
|
||||||
//
|
//
|
||||||
ASSERT (PubKeyHeader != NULL);
|
ASSERT (PubKeyHeader != NULL);
|
||||||
|
if (PubKeyHeader == NULL) {
|
||||||
|
FreePool (ValidBuffer);
|
||||||
|
FreePool (NewPubKeyIndex);
|
||||||
|
FreePool (NewPubKeyStore);
|
||||||
|
return EFI_DEVICE_ERROR;
|
||||||
|
}
|
||||||
CopyMem (CurrPtr, (UINT8*) PubKeyHeader, sizeof (VARIABLE_HEADER));
|
CopyMem (CurrPtr, (UINT8*) PubKeyHeader, sizeof (VARIABLE_HEADER));
|
||||||
Variable = (VARIABLE_HEADER*) CurrPtr;
|
Variable = (VARIABLE_HEADER*) CurrPtr;
|
||||||
Variable->DataSize = NewPubKeySize;
|
Variable->DataSize = NewPubKeySize;
|
||||||
|
|
|
@ -389,8 +389,9 @@ VariableCommonInitialize (
|
||||||
@param[in] ReclaimPubKeyStore Reclaim for public key database or not.
|
@param[in] ReclaimPubKeyStore Reclaim for public key database or not.
|
||||||
@param[in] ReclaimAnyway If TRUE, do reclaim anyway.
|
@param[in] ReclaimAnyway If TRUE, do reclaim anyway.
|
||||||
|
|
||||||
@return EFI_OUT_OF_RESOURCES No enough memory resources.
|
|
||||||
@return EFI_SUCCESS Reclaim operation has finished successfully.
|
@return EFI_SUCCESS Reclaim operation has finished successfully.
|
||||||
|
@return EFI_OUT_OF_RESOURCES No enough memory resources.
|
||||||
|
@return EFI_DEVICE_ERROR The public key database doesn't exist.
|
||||||
@return Others Unexpect error happened during reclaim operation.
|
@return Others Unexpect error happened during reclaim operation.
|
||||||
|
|
||||||
**/
|
**/
|
||||||
|
|
Loading…
Reference in New Issue