diff options
| author | Jose Luis Duran <jlduran@FreeBSD.org> | 2025-11-13 16:45:16 +0000 |
|---|---|---|
| committer | Warner Losh <imp@FreeBSD.org> | 2025-11-25 18:17:24 +0000 |
| commit | fd606b629f91560d4369ba8beda0a5ce763ee065 (patch) | |
| tree | 3daac6b15a90d4c6a1776ad562b422acdf070490 | |
| parent | 9677ae7864fa785bb994e5f07e25bad3cf1139db (diff) | |
libefivar: 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.
Note that the link above no longer exists. The commit message was kept
verbatim. An archived version of the bug report can be found at:
https://web.archive.org/web/20240714192353/bugzilla.tianocore.org/show_bug.cgi?id=1372
Obtained from: https://github.com/tianocore/edk2/commit/fd02394228ee1dc2378cccfde6098c461f96dd42
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/1894
| -rw-r--r-- | lib/libefivar/uefi-dputil.c | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/lib/libefivar/uefi-dputil.c b/lib/libefivar/uefi-dputil.c index 129b805ab650..89e049884558 100644 --- a/lib/libefivar/uefi-dputil.c +++ b/lib/libefivar/uefi-dputil.c @@ -37,7 +37,7 @@ /* * Taken from MdePkg/Library/UefiDevicePathLib/DevicePathUtilities.c - * hash 9095d37b8fe5bfc3d02adad6ba7fd7359ebc0107 2018-Jun-28 + * hash fd02394228ee1dc2378cccfde6098c461f96dd42 2019-Jan-31 */ /** @file @@ -77,12 +77,13 @@ static 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 @@ -101,19 +102,17 @@ IsDevicePathValid ( UINTN Size; UINTN NodeLength; - ASSERT (DevicePath != NULL); - - if (MaxSize == 0) { - MaxSize = MAX_UINTN; - } - // - // 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_UINTN; + } + for (Count = 0, Size = 0; !IsDevicePathEnd (DevicePath); DevicePath = NextDevicePathNode (DevicePath)) { NodeLength = DevicePathNodeLength (DevicePath); if (NodeLength < sizeof (EFI_DEVICE_PATH_PROTOCOL)) { |
