From 592d2acf6b948be1c27d74148025323422400cb5 Mon Sep 17 00:00:00 2001 From: Goldfish64 Date: Wed, 15 Jul 2020 20:16:07 -0500 Subject: [PATCH] OcFileLib: Provide workaround for buggy drivers --- Library/OcFileLib/GetFileInfo.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Library/OcFileLib/GetFileInfo.c b/Library/OcFileLib/GetFileInfo.c index e151fbc3e11..457f930eae9 100755 --- a/Library/OcFileLib/GetFileInfo.c +++ b/Library/OcFileLib/GetFileInfo.c @@ -27,6 +27,7 @@ #include #include #include +#include VOID * GetFileInfo ( @@ -52,6 +53,12 @@ GetFileInfo ( ); if (Status == EFI_BUFFER_TOO_SMALL && FileInfoSize >= MinFileInfoSize) { + // + // Some drivers (i.e. built-in 32-bit Apple HFS driver) may possibly omit null terminators from file info data. + // + if (CompareGuid (InformationType, &gEfiFileInfoGuid) && OcOverflowAddUN (FileInfoSize, sizeof (CHAR16), &FileInfoSize)) { + return NULL; + } FileInfoBuffer = AllocateZeroPool (FileInfoSize); if (FileInfoBuffer != NULL) {