Skip to content

Commit

Permalink
SignedCapsulePkg: Address NULL pointer dereference case.
Browse files Browse the repository at this point in the history
Original code GetFmpImageDescriptors for OriginalFmpImageInfoBuf
pointer, if failed, return a NULL pointer. The OriginalFmpImageInfoBuf
should not be NULL and the NULL pointer dereference case
should be false positive.

Cc: Jiewen Yao <[email protected]>
Cc: Chao Zhang <[email protected]>
Signed-off-by: Vin Xue <[email protected]>
Reviewed-by: Jiewen Yao <[email protected]>
  • Loading branch information
vinxue authored and mergify[bot] committed Jul 16, 2020
1 parent 1da651c commit 21a23e6
Showing 1 changed file with 21 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -681,32 +681,35 @@ FindMatchingFmpHandles (
//
// Loop through the set of EFI_FIRMWARE_IMAGE_DESCRIPTORs.
//
FmpImageInfoBuf = OriginalFmpImageInfoBuf;
MatchFound = FALSE;
for (Index2 = 0; Index2 < FmpImageInfoCount; Index2++) {
for (Index3 = 0; Index3 < mSystemFmpPrivate->DescriptorCount; Index3++) {
MatchFound = CompareGuid (
&FmpImageInfoBuf->ImageTypeId,
&mSystemFmpPrivate->ImageDescriptor[Index3].ImageTypeId
);
if (OriginalFmpImageInfoBuf != NULL) {
FmpImageInfoBuf = OriginalFmpImageInfoBuf;

for (Index2 = 0; Index2 < FmpImageInfoCount; Index2++) {
for (Index3 = 0; Index3 < mSystemFmpPrivate->DescriptorCount; Index3++) {
MatchFound = CompareGuid (
&FmpImageInfoBuf->ImageTypeId,
&mSystemFmpPrivate->ImageDescriptor[Index3].ImageTypeId
);
if (MatchFound) {
break;
}
}
if (MatchFound) {
break;
}
//
// Increment the buffer pointer ahead by the size of the descriptor
//
FmpImageInfoBuf = (EFI_FIRMWARE_IMAGE_DESCRIPTOR *)(((UINT8 *)FmpImageInfoBuf) + DescriptorSize);
}
if (MatchFound) {
break;
HandleBuffer[*HandleCount] = HandleBuffer[Index];
(*HandleCount)++;
}
//
// Increment the buffer pointer ahead by the size of the descriptor
//
FmpImageInfoBuf = (EFI_FIRMWARE_IMAGE_DESCRIPTOR *)(((UINT8 *)FmpImageInfoBuf) + DescriptorSize);
}
if (MatchFound) {
HandleBuffer[*HandleCount] = HandleBuffer[Index];
(*HandleCount)++;
}

FreePool (OriginalFmpImageInfoBuf);
FreePool (OriginalFmpImageInfoBuf);
}
}

if ((*HandleCount) == 0) {
Expand Down

0 comments on commit 21a23e6

Please sign in to comment.