public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: Ruiyu Ni <ruiyu.ni@intel.com>
To: edk2-devel@lists.01.org
Cc: Jaben Carsey <jaben.carsey@intel.com>
Subject: [PATCH 3/6] ShellPkg: Fix FindFiles() to handle "fsx:EFI\BOOT" path
Date: Mon,  8 Aug 2016 18:28:31 +0800	[thread overview]
Message-ID: <20160808102834.129372-4-ruiyu.ni@intel.com> (raw)
In-Reply-To: <20160808102834.129372-1-ruiyu.ni@intel.com>

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.ni@intel.com>
Cc: Jaben Carsey <jaben.carsey@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



  parent reply	other threads:[~2016-08-08 10:28 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-08 10:28 [PATCH 0/6] Fix shell TAB completion issue and bugs in LS command Ruiyu Ni
2016-08-08 10:28 ` [PATCH 1/6] ShellPkg: TAB logic incorrectly chops out fs0: when typing fs0:<TAB> Ruiyu Ni
2016-08-08 10:28 ` [PATCH 2/6] ShellPkg: TAB logic incorrectly shows files in CWD when typing \<TAB> Ruiyu Ni
2016-08-08 10:28 ` Ruiyu Ni [this message]
2016-08-08 10:28 ` [PATCH 4/6] MdePkg: Enhance PathRemoveLastItem() to support "FS0:File.txt" Ruiyu Ni
2016-08-08 10:28 ` [PATCH 5/6] ShellPkg/ls: Fix to support "ls fs0:File.txt" Ruiyu Ni
2016-08-08 10:28 ` [PATCH 6/6] ShellPkg/ls: Display the correct directory path Ruiyu Ni

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160808102834.129372-4-ruiyu.ni@intel.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox