]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ShellPkg: Fix bug introduced by r17730.
authorHeyi Guo <heyi.guo@linaro.org>
Sat, 4 Jul 2015 02:26:54 +0000 (02:26 +0000)
committershenshushi <shenshushi@Edk2>
Sat, 4 Jul 2015 02:26:54 +0000 (02:26 +0000)
CurrentFilePattern is only part of FilePattern and will be less than or equal to FilePattern. If we use StrCpyS to replace StrnCpy, it will cause assert when FilePattern is longer.
The bug can be replayed when we cd to one directory and run ls command.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Heyi Guo <heyi.guo@linaro.org>
Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Reviewed-by: Qiu Shumin <shumin.qiu@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@17821 6f19259b-4bc3-4df7-8a09-765794883524

ShellPkg/Application/Shell/ShellProtocol.c

index 249e1e19d80264ef4ebe4e8f6fbab99534fb71a8..6a248522b56d0912851835b8af0c4a000fd609e8 100644 (file)
@@ -2220,7 +2220,7 @@ ShellSearchHandle(
 \r
   CurrentFilePattern = AllocateZeroPool((NextFilePatternStart-FilePattern+1)*sizeof(CHAR16));\r
   ASSERT(CurrentFilePattern != NULL);\r
-  StrCpyS(CurrentFilePattern, NextFilePatternStart-FilePattern+1, FilePattern);\r
+  StrnCpyS(CurrentFilePattern, NextFilePatternStart-FilePattern+1, FilePattern, NextFilePatternStart-FilePattern);\r
 \r
   if (CurrentFilePattern[0]   == CHAR_NULL\r
     &&NextFilePatternStart[0] == CHAR_NULL\r