From d20dd3510529e8d59da4804e91da2f29383e1c30 Mon Sep 17 00:00:00 2001 From: Download-Fritz Date: Tue, 11 Jun 2019 21:41:34 +0200 Subject: [PATCH] OcBootManagementLib: Fix potential OOB access --- Library/OcBootManagementLib/BootEntryInfo.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Library/OcBootManagementLib/BootEntryInfo.c b/Library/OcBootManagementLib/BootEntryInfo.c index 0642fbff..a83621b6 100644 --- a/Library/OcBootManagementLib/BootEntryInfo.c +++ b/Library/OcBootManagementLib/BootEntryInfo.c @@ -291,6 +291,7 @@ InternalSetBootEntryFlags ( { EFI_DEVICE_PATH_PROTOCOL *DevicePathWalker; CONST CHAR16 *Path; + UINTN Len; BootEntry->IsFolder = FALSE; BootEntry->IsRecovery = FALSE; @@ -306,7 +307,8 @@ InternalSetBootEntryFlags ( if ((DevicePathType (DevicePathWalker) == MEDIA_DEVICE_PATH) && (DevicePathSubType (DevicePathWalker) == MEDIA_FILEPATH_DP)) { Path = ((FILEPATH_DEVICE_PATH *) DevicePathWalker)->PathName; - if (Path[StrLen (Path) - 1] == L'\\') { + Len = StrLen (Path); + if ((Len > 0) && (Path[Len - 1] == L'\\')) { BootEntry->IsFolder = TRUE; } if (StrStr (Path, L"com.apple.recovery.boot") != NULL) {