diff options
author | lgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524> | 2011-12-19 09:00:58 +0000 |
---|---|---|
committer | lgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524> | 2011-12-19 09:00:58 +0000 |
commit | bdc9d5a5d5b22bb96e075e04211c450f76bef595 (patch) | |
tree | 014642801c9f0a61392459d948a5441896c45595 | |
parent | dc458c90b357db2f1793d36bb1965f47f4e45382 (diff) | |
download | edk2-platforms-bdc9d5a5d5b22bb96e075e04211c450f76bef595.tar.xz |
Add more check to make sure the valid pointer be used.
Signed-off-by: lgao4
Reviewed-by: rsun3
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@12886 6f19259b-4bc3-4df7-8a09-765794883524
-rw-r--r-- | MdeModulePkg/Core/Dxe/Dispatcher/Dispatcher.c | 56 |
1 files changed, 29 insertions, 27 deletions
diff --git a/MdeModulePkg/Core/Dxe/Dispatcher/Dispatcher.c b/MdeModulePkg/Core/Dxe/Dispatcher/Dispatcher.c index 5f8e383158..16fd793c12 100644 --- a/MdeModulePkg/Core/Dxe/Dispatcher/Dispatcher.c +++ b/MdeModulePkg/Core/Dxe/Dispatcher/Dispatcher.c @@ -745,40 +745,42 @@ FvIsBeingProcesssed ( //
// Get the full FV header based on FVB protocol.
//
+ ASSERT (Fvb != NULL);
Status = GetFwVolHeader (Fvb, &FwVolHeader);
- if (EFI_ERROR (Status)) {
- FwVolHeader = NULL;
- } else if (VerifyFvHeaderChecksum (FwVolHeader) && FwVolHeader->ExtHeaderOffset != 0) {
- ExtHeaderOffset = (UINT32) FwVolHeader->ExtHeaderOffset;
- BlockMap = FwVolHeader->BlockMap;
- LbaIndex = 0;
- LbaOffset = 0;
- //
- // Find LbaIndex and LbaOffset for FV extension header based on BlockMap.
- //
- while ((BlockMap->NumBlocks != 0) || (BlockMap->Length != 0)) {
- for (Index = 0; Index < BlockMap->NumBlocks && ExtHeaderOffset >= BlockMap->Length; Index ++) {
- ExtHeaderOffset -= BlockMap->Length;
- LbaIndex ++;
+ if (!EFI_ERROR (Status)) {
+ ASSERT (FwVolHeader != NULL);
+ if (VerifyFvHeaderChecksum (FwVolHeader) && FwVolHeader->ExtHeaderOffset != 0) {
+ ExtHeaderOffset = (UINT32) FwVolHeader->ExtHeaderOffset;
+ BlockMap = FwVolHeader->BlockMap;
+ LbaIndex = 0;
+ LbaOffset = 0;
+ //
+ // Find LbaIndex and LbaOffset for FV extension header based on BlockMap.
+ //
+ while ((BlockMap->NumBlocks != 0) || (BlockMap->Length != 0)) {
+ for (Index = 0; Index < BlockMap->NumBlocks && ExtHeaderOffset >= BlockMap->Length; Index ++) {
+ ExtHeaderOffset -= BlockMap->Length;
+ LbaIndex ++;
+ }
+ //
+ // Check whether FvExtHeader is crossing the multi block range.
+ //
+ if (Index < BlockMap->NumBlocks) {
+ LbaOffset = ExtHeaderOffset;
+ break;
+ }
+ BlockMap++;
}
//
- // Check whether FvExtHeader is crossing the multi block range.
+ // Read FvNameGuid from FV extension header.
//
- if (Index < BlockMap->NumBlocks) {
- LbaOffset = ExtHeaderOffset;
- break;
+ Status = ReadFvbData (Fvb, &LbaIndex, &LbaOffset, sizeof (FvNameGuid), (UINT8 *) &FvNameGuid);
+ if (!EFI_ERROR (Status)) {
+ FvNameGuidIsFound = TRUE;
}
- BlockMap++;
- }
- //
- // Read FvNameGuid from FV extension header.
- //
- Status = ReadFvbData (Fvb, &LbaIndex, &LbaOffset, sizeof (FvNameGuid), (UINT8 *) &FvNameGuid);
- if (!EFI_ERROR (Status)) {
- FvNameGuidIsFound = TRUE;
}
+ CoreFreePool (FwVolHeader);
}
- CoreFreePool (FwVolHeader);
}
if (FvNameGuidIsFound) {
|