Fix Klockwork issue flagged in BootloaderCommonPkg (#646)

Fix for: Klockwork flags possible null pointer variable 'CompressHdr'
being dereferenced.

Signed-off-by: Vegnish Rao <vegnish.rao.paramesura.rao@intel.com>

Co-authored-by: Vegnish Rao <vegnish.rao.paramesura.rao@intel.com>
This commit is contained in:
Vegnish Rao 2020-04-08 08:22:24 +08:00 committed by GitHub
parent e738eeafac
commit de49b23c7e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 0 deletions

View File

@ -760,6 +760,10 @@ LoadComponentWithCallback (
// Component must have LOADER_COMPRESSED_HEADER
Status = EFI_UNSUPPORTED;
CompressHdr = (LOADER_COMPRESSED_HEADER *)CompData;
if (CompressHdr == NULL) {
return EFI_NOT_FOUND;
}
if (IS_COMPRESSED (CompressHdr)) {
SignedDataLen = sizeof (LOADER_COMPRESSED_HEADER) + CompressHdr->CompressedSize;
if (SignedDataLen <= CompLen) {