diff options
author | Mike Turner <miketur@microsoft.com> | 2018-12-11 14:10:33 +0800 |
---|---|---|
committer | Liming Gao <liming.gao@intel.com> | 2019-01-31 20:19:22 +0800 |
commit | ca67441558cbe7d482ebf9506fee01b82447ddf1 (patch) | |
tree | 7658f3b4cfbd6e3d6abfb8aa60eac62842ab6062 /BaseTools/Source/C/DevicePath | |
parent | fd02394228ee1dc2378cccfde6098c461f96dd42 (diff) | |
download | edk2-ca67441558cbe7d482ebf9506fee01b82447ddf1.zip edk2-ca67441558cbe7d482ebf9506fee01b82447ddf1.tar.gz edk2-ca67441558cbe7d482ebf9506fee01b82447ddf1.tar.bz2 |
BaseTools/DevicePath: Add a checking step
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>
Reviewed-by: Liming Gao <liming.gao@intel.com>
Diffstat (limited to 'BaseTools/Source/C/DevicePath')
-rw-r--r-- | BaseTools/Source/C/DevicePath/DevicePathUtilities.c | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/BaseTools/Source/C/DevicePath/DevicePathUtilities.c b/BaseTools/Source/C/DevicePath/DevicePathUtilities.c index f8a41ff..3b3abc6 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,19 +60,17 @@ IsDevicePathValid ( UINTN Size;
UINTN NodeLength;
- ASSERT (DevicePath != NULL);
-
- if (MaxSize == 0) {
- MaxSize = MAX_UINT32;
- }
-
//
- // Validate the input size big enough to touch the first node.
+ // Validate the input whether exists and its size big enough to touch the first node
//
- if (MaxSize < sizeof (EFI_DEVICE_PATH_PROTOCOL)) {
+ if (DevicePath == NULL || (MaxSize > 0 && MaxSize < END_DEVICE_PATH_LENGTH)) {
return FALSE;
}
+ if (MaxSize == 0) {
+ MaxSize = MAX_UINT32;
+ }
+
for (Count = 0, Size = 0; !IsDevicePathEnd (DevicePath); DevicePath = NextDevicePathNode (DevicePath)) {
NodeLength = DevicePathNodeLength (DevicePath);
if (NodeLength < sizeof (EFI_DEVICE_PATH_PROTOCOL)) {
|