From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by ml01.01.org (Postfix) with ESMTP id 535E51A1E1B for ; Mon, 8 Aug 2016 03:28:42 -0700 (PDT) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga102.fm.intel.com with ESMTP; 08 Aug 2016 03:28:41 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.28,489,1464678000"; d="scan'208";a="861587493" Received: from ray-dev.ccr.corp.intel.com ([10.239.9.25]) by orsmga003.jf.intel.com with ESMTP; 08 Aug 2016 03:28:40 -0700 From: Ruiyu Ni To: edk2-devel@lists.01.org Cc: Jaben Carsey Date: Mon, 8 Aug 2016 18:28:31 +0800 Message-Id: <20160808102834.129372-4-ruiyu.ni@intel.com> X-Mailer: git-send-email 2.9.0.windows.1 In-Reply-To: <20160808102834.129372-1-ruiyu.ni@intel.com> References: <20160808102834.129372-1-ruiyu.ni@intel.com> Subject: [PATCH 3/6] ShellPkg: Fix FindFiles() to handle "fsx:EFI\BOOT" path X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 08 Aug 2016 10:28:42 -0000 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 Cc: Jaben Carsey --- 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