From a5e28cc1d03d762b5c87b08da9e614022dea5eb2 Mon Sep 17 00:00:00 2001 From: Heyi Guo Date: Sat, 4 Jul 2015 02:26:54 +0000 Subject: ShellPkg: Fix bug introduced by r17730. 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 Reviewed-by: Ard Biesheuvel Reviewed-by: Qiu Shumin git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@17821 6f19259b-4bc3-4df7-8a09-765794883524 --- ShellPkg/Application/Shell/ShellProtocol.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ShellPkg/Application/Shell/ShellProtocol.c b/ShellPkg/Application/Shell/ShellProtocol.c index 249e1e19d8..6a248522b5 100644 --- a/ShellPkg/Application/Shell/ShellProtocol.c +++ b/ShellPkg/Application/Shell/ShellProtocol.c @@ -2220,7 +2220,7 @@ ShellSearchHandle( CurrentFilePattern = AllocateZeroPool((NextFilePatternStart-FilePattern+1)*sizeof(CHAR16)); ASSERT(CurrentFilePattern != NULL); - StrCpyS(CurrentFilePattern, NextFilePatternStart-FilePattern+1, FilePattern); + StrnCpyS(CurrentFilePattern, NextFilePatternStart-FilePattern+1, FilePattern, NextFilePatternStart-FilePattern); if (CurrentFilePattern[0] == CHAR_NULL &&NextFilePatternStart[0] == CHAR_NULL -- cgit v1.2.3