From: "Feng, YunhuaX" <yunhuax.feng@intel.com>
To: "devel@edk2.groups.io" <devel@edk2.groups.io>
Cc: "Feng, Bob C" <bob.c.feng@intel.com>,
"Gao, Liming" <liming.gao@intel.com>
Subject: [edk2-staging][PATCH] BaseTools/Fmmt: Enhance for check input FD size
Date: Thu, 2 Apr 2020 09:23:11 +0000 [thread overview]
Message-ID: <b5b6eed00ed64598973022a6e87d351c@intel.com> (raw)
[-- 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 --]
reply other threads:[~2020-04-02 9:23 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=b5b6eed00ed64598973022a6e87d351c@intel.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox