mirror of https://github.com/acidanthera/audk.git
BaseTools/GenFfs: 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:
parent
02875ba228
commit
2cb8743524
|
@ -1,7 +1,7 @@
|
||||||
/** @file
|
/** @file
|
||||||
This file contains functions required to generate a Firmware File System file.
|
This file contains functions required to generate a Firmware File System file.
|
||||||
|
|
||||||
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
|
This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
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
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
|
@ -842,7 +842,7 @@ Returns:
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status) || (FileBuffer == NULL)) {
|
||||||
goto Finish;
|
goto Finish;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -915,22 +915,24 @@ Returns:
|
||||||
//
|
//
|
||||||
// Open output file to write ffs data.
|
// Open output file to write ffs data.
|
||||||
//
|
//
|
||||||
remove(OutputFileName);
|
if (OutputFileName != NULL) {
|
||||||
FfsFile = fopen (LongFilePath (OutputFileName), "wb");
|
remove(OutputFileName);
|
||||||
if (FfsFile == NULL) {
|
FfsFile = fopen (LongFilePath (OutputFileName), "wb");
|
||||||
Error (NULL, 0, 0001, "Error opening file", OutputFileName);
|
if (FfsFile == NULL) {
|
||||||
goto Finish;
|
Error (NULL, 0, 0001, "Error opening file", OutputFileName);
|
||||||
}
|
goto Finish;
|
||||||
//
|
}
|
||||||
// write header
|
//
|
||||||
//
|
// write header
|
||||||
fwrite (&FfsFileHeader, 1, HeaderSize, FfsFile);
|
//
|
||||||
//
|
fwrite (&FfsFileHeader, 1, HeaderSize, FfsFile);
|
||||||
// write data
|
//
|
||||||
//
|
// write data
|
||||||
fwrite (FileBuffer, 1, FileSize - HeaderSize, FfsFile);
|
//
|
||||||
|
fwrite (FileBuffer, 1, FileSize - HeaderSize, FfsFile);
|
||||||
|
|
||||||
fclose (FfsFile);
|
fclose (FfsFile);
|
||||||
|
}
|
||||||
|
|
||||||
Finish:
|
Finish:
|
||||||
if (InputFileName != NULL) {
|
if (InputFileName != NULL) {
|
||||||
|
|
Loading…
Reference in New Issue