BaseTools/GenSec: Avoid possible NULL pointer dereference

Cc: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
This commit is contained in:
Hao Wu 2016-10-11 10:22:13 +08:00
parent 18c2a7621d
commit 248fce0329
1 changed files with 16 additions and 2 deletions

View File

@ -1,7 +1,7 @@
/** @file
Creates output file that is a properly formed section per the PI spec.
Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved.<BR>
Copyright (c) 2004 - 2016, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@ -667,6 +667,10 @@ Returns:
return Status;
}
if (FileBuffer == NULL) {
return EFI_OUT_OF_RESOURCES;
}
CompressFunction = NULL;
//
@ -731,6 +735,10 @@ Returns:
return Status;
}
if (FileBuffer == NULL) {
return EFI_OUT_OF_RESOURCES;
}
}
DebugMsg (NULL, 0, 9, "comprss file size",
@ -889,6 +897,10 @@ Returns:
return Status;
}
if (FileBuffer == NULL) {
return EFI_OUT_OF_RESOURCES;
}
if (InputLength == 0) {
Error (NULL, 0, 2000, "Invalid parameter", "the size of input file %s can't be zero", InputFileName);
return EFI_NOT_FOUND;
@ -1365,7 +1377,9 @@ Returns:
//
// GuidValue is only required by Guided section.
//
if ((SectType != EFI_SECTION_GUID_DEFINED) && (CompareGuid (&VendorGuid, &mZeroGuid) != 0)) {
if ((SectType != EFI_SECTION_GUID_DEFINED) &&
(SectionName != NULL) &&
(CompareGuid (&VendorGuid, &mZeroGuid) != 0)) {
fprintf (stdout, "Warning: the input guid value is not required for this section type %s\n", SectionName);
}