git: fd606b629f91 - main - libefivar: Add a checking step
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 25 Nov 2025 18:17:32 UTC
The branch main has been updated by imp:
URL: https://cgit.FreeBSD.org/src/commit/?id=fd606b629f91560d4369ba8beda0a5ce763ee065
commit fd606b629f91560d4369ba8beda0a5ce763ee065
Author: Jose Luis Duran <jlduran@FreeBSD.org>
AuthorDate: 2025-11-13 16:45:16 +0000
Commit: Warner Losh <imp@FreeBSD.org>
CommitDate: 2025-11-25 18:17:24 +0000
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
---
lib/libefivar/uefi-dputil.c | 19 +++++++++----------
1 file 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)) {