When the FilePattern is similar to "fsx:EFI\BOOT", FindFiles()
cannot handle it correctly because it always assumes there is
"\\" after "fsx:".

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <ruiyu...@intel.com>
Cc: Jaben Carsey <jaben.car...@intel.com>
---
 ShellPkg/Application/Shell/ShellProtocol.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/ShellPkg/Application/Shell/ShellProtocol.c 
b/ShellPkg/Application/Shell/ShellProtocol.c
index 55a1e43..0e5d954 100644
--- a/ShellPkg/Application/Shell/ShellProtocol.c
+++ b/ShellPkg/Application/Shell/ShellProtocol.c
@@ -2434,15 +2434,14 @@ ShellSearchHandle(
          ){
         if (UnicodeCollation->MetaiMatch(UnicodeCollation, 
(CHAR16*)ShellInfoNode->FileName, CurrentFilePattern)){
           if (ShellInfoNode->FullName != NULL && 
StrStr(ShellInfoNode->FullName, L":") == NULL) {
-            Size = StrSize(ShellInfoNode->FullName);
-            Size += StrSize(MapName) + sizeof(CHAR16);
+            Size = StrSize (ShellInfoNode->FullName) + StrSize (MapName);
             NewFullName = AllocateZeroPool(Size);
             if (NewFullName == NULL) {
               Status = EFI_OUT_OF_RESOURCES;
             } else {
-              StrCpyS(NewFullName, Size/sizeof(CHAR16), MapName);
-              StrCatS(NewFullName, Size/sizeof(CHAR16), 
ShellInfoNode->FullName+1);
-              FreePool((VOID*)ShellInfoNode->FullName);
+              StrCpyS(NewFullName, Size / sizeof(CHAR16), MapName);
+              StrCatS(NewFullName, Size / sizeof(CHAR16), 
ShellInfoNode->FullName);
+              FreePool ((VOID *) ShellInfoNode->FullName);
               ShellInfoNode->FullName = NewFullName;
             }
           }
@@ -2572,8 +2571,8 @@ EfiShellFindFiles(
 
   PatternCopy = PathCleanUpDirectories(PatternCopy);
 
-  Count = StrStr(PatternCopy, L":") - PatternCopy;
-  Count += 2;
+  Count = StrStr(PatternCopy, L":") - PatternCopy + 1;
+  ASSERT (Count <= StrLen (PatternCopy));
 
   ASSERT(MapName == NULL);
   MapName = StrnCatGrow(&MapName, NULL, PatternCopy, Count);
-- 
2.9.0.windows.1

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel

Reply via email to