From d25d59cb7ee608deb60137389c2461c6d937f669 Mon Sep 17 00:00:00 2001 From: Ruiyu Ni Date: Fri, 5 Aug 2016 13:12:56 +0800 Subject: ShellPkg: Fix FindFiles() to handle "fsx:EFI\BOOT" path 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 Reviewed-by: Jaben Carsey Reviewed-by: Tapan Shah --- ShellPkg/Application/Shell/ShellProtocol.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'ShellPkg') 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); -- cgit v1.1