* [edk2-staging][PATCH] BaseTools/Fmmt: Enhance for check input FD size
@ 2020-04-02 9:23 Feng, YunhuaX
0 siblings, 0 replies; only message in thread
From: Feng, YunhuaX @ 2020-04-02 9:23 UTC (permalink / raw)
To: devel@edk2.groups.io; +Cc: Feng, Bob C, Gao, Liming
[-- Attachment #1: Type: text/plain, Size: 1760 bytes --]
Enhance for check input FD if empty file or not.
Cc: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Signed-off-by: Yunhua Feng <yunhuax.feng@intel.com>
---
BaseTools/Source/C/FMMT/FirmwareModuleManagement.c | 2 +-
BaseTools/Source/C/FMMT/FmmtLib.c | 5 +++++
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/BaseTools/Source/C/FMMT/FirmwareModuleManagement.c b/BaseTools/Source/C/FMMT/FirmwareModuleManagement.c
index db9b585541..4252c698aa 100644
--- a/BaseTools/Source/C/FMMT/FirmwareModuleManagement.c
+++ b/BaseTools/Source/C/FMMT/FirmwareModuleManagement.c
@@ -833,11 +833,11 @@ FmmtImageView (
}
Status = LibFindFvInFd (InputFile, &LocalFdData);
if (EFI_ERROR(Status)) {
- Error("FMMT", 0, 1001, "Error while search FV in FD", "");
+ Error("FMMT", 0, 1001, "Error while search FV in FD", FdInName);
fclose (InputFile);
return EFI_ABORTED;
}
CurrentFv = LocalFdData->Fv;
diff --git a/BaseTools/Source/C/FMMT/FmmtLib.c b/BaseTools/Source/C/FMMT/FmmtLib.c
index cdbee3d629..30deec532f 100644
--- a/BaseTools/Source/C/FMMT/FmmtLib.c
+++ b/BaseTools/Source/C/FMMT/FmmtLib.c
@@ -265,10 +265,15 @@ LibFindFvInFd (
}
FdBufferOri = FdBuffer;
FdBufferEnd = FdBuffer + FdSize;
+ if (FdSize < sizeof(EFI_FIRMWARE_VOLUME_HEADER)) {
+ Error ("FMMT", 0, 0002, "Error Check the input FD, Please make sure the FD is valid", "Check FD size error!");
+ return EFI_ABORTED;
+ }
+
while (FdBuffer <= FdBufferEnd - sizeof (EFI_FIRMWARE_VOLUME_HEADER)) {
FvHeader = (EFI_FIRMWARE_VOLUME_HEADER *) FdBuffer;
//
// Copy 4 bytes of fd data to check the _FVH signature
//
--
2.12.2.windows.2
[-- Attachment #2: winmail.dat --]
[-- Type: application/ms-tnef, Size: 5714 bytes --]
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2020-04-02 9:23 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-04-02 9:23 [edk2-staging][PATCH] BaseTools/Fmmt: Enhance for check input FD size Feng, YunhuaX
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox