mirror of https://github.com/acidanthera/audk.git
BaseTools/GenSec: Fix potential null pointer dereference
Cc: Yonghong Zhu <yonghong.zhu@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Hao Wu <hao.a.wu@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com>
This commit is contained in:
parent
ae0fbb7f5a
commit
c40dbe5e7b
|
@ -1333,10 +1333,20 @@ Returns:
|
|||
DummyFileSize = ftell (DummyFile);
|
||||
fseek (DummyFile, 0, SEEK_SET);
|
||||
DummyFileBuffer = (UINT8 *) malloc (DummyFileSize);
|
||||
if (DummyFileBuffer == NULL) {
|
||||
fclose(DummyFile);
|
||||
Error (NULL, 0, 4001, "Resource", "memory cannot be allcoated");
|
||||
goto Finish;
|
||||
}
|
||||
|
||||
fread(DummyFileBuffer, 1, DummyFileSize, DummyFile);
|
||||
fclose(DummyFile);
|
||||
DebugMsg (NULL, 0, 9, "Dummy files", "the dummy file name is %s and the size is %u bytes", DummyFileName, (unsigned) DummyFileSize);
|
||||
|
||||
if (InputFileName == NULL) {
|
||||
Error (NULL, 0, 4001, "Resource", "memory cannot be allcoated");
|
||||
goto Finish;
|
||||
}
|
||||
InFile = fopen(LongFilePath(InputFileName[0]), "rb");
|
||||
if (InFile == NULL) {
|
||||
Error (NULL, 0, 0001, "Error opening file", InputFileName[0]);
|
||||
|
@ -1347,6 +1357,12 @@ Returns:
|
|||
InFileSize = ftell (InFile);
|
||||
fseek (InFile, 0, SEEK_SET);
|
||||
InFileBuffer = (UINT8 *) malloc (InFileSize);
|
||||
if (InFileBuffer == NULL) {
|
||||
fclose(InFile);
|
||||
Error (NULL, 0, 4001, "Resource", "memory cannot be allcoated");
|
||||
goto Finish;
|
||||
}
|
||||
|
||||
fread(InFileBuffer, 1, InFileSize, InFile);
|
||||
fclose(InFile);
|
||||
DebugMsg (NULL, 0, 9, "Input files", "the input file name is %s and the size is %u bytes", InputFileName[0], (unsigned) InFileSize);
|
||||
|
|
Loading…
Reference in New Issue