Message ID | 1435916081-27645-3-git-send-email-heyi.guo@linaro.org |
---|---|
State | New |
Headers | show |
On 3 July 2015 at 11:34, Heyi Guo <heyi.guo@linaro.org> wrote: > 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> > --- > 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/
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
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> --- ShellPkg/Application/Shell/ShellProtocol.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)