From: Shenglei Zhang <shenglei.zhang@intel.com>
To: edk2-devel@lists.01.org
Cc: Bob Feng <bob.c.feng@intel.com>,
Liming Gao <liming.gao@intel.com>,
Yonghong Zhu <yonghong.zhu@intel.com>
Subject: [PATCH v2 2/2] BaseTools/DevicePath: Add a checking step
Date: Wed, 12 Dec 2018 11:10:10 +0800 [thread overview]
Message-ID: <20181212031011.20996-2-shenglei.zhang@intel.com> (raw)
In-Reply-To: <20181212031011.20996-1-shenglei.zhang@intel.com>
Add a checking step in DevicePathUtilities.c
to verify DevicePath.
https://bugzilla.tianocore.org/show_bug.cgi?id=1372
v2: Remove ASSERT() and the redundant checking step.
Update related description.
Cc: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Shenglei Zhang <shenglei.zhang@intel.com>
---
.../Source/C/DevicePath/DevicePathUtilities.c | 17 ++++++++---------
1 file changed, 8 insertions(+), 9 deletions(-)
diff --git a/BaseTools/Source/C/DevicePath/DevicePathUtilities.c b/BaseTools/Source/C/DevicePath/DevicePathUtilities.c
index f8a41ff97d..e0399cfea7 100644
--- a/BaseTools/Source/C/DevicePath/DevicePathUtilities.c
+++ b/BaseTools/Source/C/DevicePath/DevicePathUtilities.c
@@ -36,12 +36,13 @@ CONST EFI_DEVICE_PATH_PROTOCOL mUefiDevicePathLibEndDevicePath = {
/**
Determine whether a given device path is valid.
- If DevicePath is NULL, then ASSERT().
@param DevicePath A pointer to a device path data structure.
@param MaxSize The maximum size of the device path data structure.
@retval TRUE DevicePath is valid.
+ @retval FALSE DevicePath is NULL.
+ @retval FALSE Maxsize is less than sizeof(EFI_DEVICE_PATH_PROTOCOL).
@retval FALSE The length of any node node in the DevicePath is less
than sizeof (EFI_DEVICE_PATH_PROTOCOL).
@retval FALSE If MaxSize is not zero, the size of the DevicePath
@@ -59,17 +60,15 @@ IsDevicePathValid (
UINTN Size;
UINTN NodeLength;
- ASSERT (DevicePath != NULL);
+ //
+ // Validate the input whether exists and its size big enough to touch the first node
+ //
+ if (DevicePath == NULL || (MaxSize > 0 && MaxSize < END_DEVICE_PATH_LENGTH)) {
+ return FALSE;
+ }
if (MaxSize == 0) {
MaxSize = MAX_UINT32;
- }
-
- //
- // Validate the input size big enough to touch the first node.
- //
- if (MaxSize < sizeof (EFI_DEVICE_PATH_PROTOCOL)) {
- return FALSE;
}
for (Count = 0, Size = 0; !IsDevicePathEnd (DevicePath); DevicePath = NextDevicePathNode (DevicePath)) {
--
2.18.0.windows.1
next prev parent reply other threads:[~2018-12-12 3:10 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-12-12 3:10 [PATCH v2 0/2] Add a checking step in MdePkg and Basetools Shenglei Zhang
2018-12-12 3:10 ` Shenglei Zhang [this message]
2019-01-29 3:08 ` [PATCH v2 2/2] BaseTools/DevicePath: Add a checking step Gao, Liming
2018-12-12 3:10 ` [PATCH v2 2/2] MdePkg/UefiDevicePathLib: " Shenglei Zhang
2019-01-29 1:29 ` Gao, Liming
2019-01-29 3:41 ` Ni, Ray
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=20181212031011.20996-2-shenglei.zhang@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