Reviewed-by:  Qiu Shumin <shumin....@intel.com> 

-----Original Message-----
From: Heyi Guo [mailto:heyi....@linaro.org] 
Sent: Friday, July 03, 2015 5:35 PM
To: edk2-devel@lists.sourceforge.net
Subject: [edk2] [PATCH 2/2] 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 <heyi....@linaro.org>
---
 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 249e1e1..6a24852 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
--
2.1.4


------------------------------------------------------------------------------
Don't Limit Your Business. Reach for the Cloud.
GigeNET's Cloud Solutions provide you with the tools and support that
you need to offload your IT needs and focus on growing your business.
Configured For All Businesses. Start Your Cloud Today.
https://www.gigenetcloud.com/
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/edk2-devel

------------------------------------------------------------------------------
Don't Limit Your Business. Reach for the Cloud.
GigeNET's Cloud Solutions provide you with the tools and support that
you need to offload your IT needs and focus on growing your business.
Configured For All Businesses. Start Your Cloud Today.
https://www.gigenetcloud.com/
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/edk2-devel

Reply via email to