Harden BlpDuplicateDevicePath against malformed device paths
All checks were successful
Builds / ExectOS (amd64) (push) Successful in 46s
Builds / ExectOS (i686) (push) Successful in 47s

This commit is contained in:
Aiken Harris 2025-07-29 12:15:27 +02:00 committed by CodingWorkshop Signing Team
parent b0aabf96b8
commit 7fce778ee4
Signed by: CodingWorkshop Signing Team
GPG Key ID: 6DC88369C82795D2

View File

@ -927,17 +927,25 @@ BlpDuplicateDevicePath(IN PEFI_DEVICE_PATH_PROTOCOL DevicePath)
EFI_STATUS Status;
UINT Length = 0;
/* Check if the input device path is NULL */
if(!DevicePath)
{
/* Nothing to duplicate */
return NULL;
}
/* Start iterating from the beginning of the device path */
DevicePathNode = DevicePath;
/* Get the device path length */
while(TRUE)
{
Length += *(PUSHORT)DevicePath->Length;
Length += *(PUSHORT)DevicePathNode->Length;
if(DevicePathNode->Type == EFI_END_DEVICE_PATH)
{
break;
}
DevicePathNode = (PEFI_DEVICE_PATH_PROTOCOL)((PUCHAR)DevicePathNode + *(PUSHORT)DevicePath->Length);
DevicePathNode = (PEFI_DEVICE_PATH_PROTOCOL)((PUCHAR)DevicePathNode + *(PUSHORT)DevicePathNode->Length);
}
/* Check length */