Reviewed-by: Jaben Carsey <[email protected]>
> -----Original Message----- > From: Ni, Ruiyu > Sent: Friday, April 08, 2016 3:10 AM > To: Qiu, Shumin <[email protected]>; [email protected] > Cc: Carsey, Jaben <[email protected]>; Qiu, Shumin > <[email protected]> > Subject: RE: [edk2] [PATCH] ShellPkg: Fix Shell ASSERT when mv file with cwd > is NULL. > Importance: High > > > > Reviewed-by: Ruiyu Ni <[email protected]> > > >-----Original Message----- > >From: edk2-devel [mailto:[email protected]] On Behalf Of > Qiu Shumin > >Sent: Friday, April 8, 2016 3:54 PM > >To: [email protected] > >Cc: Carsey, Jaben <[email protected]>; Ni, Ruiyu > <[email protected]>; Qiu, Shumin <[email protected]> > >Subject: [edk2] [PATCH] ShellPkg: Fix Shell ASSERT when mv file with cwd is > NULL. > > > >Shell will ASSERT when doing the following operation: > >"" > >Shell> mv fs2:\file1 fs2:\file2 > >"" > >This patch add NULL pointer check to fix this issue. > > > >Cc: Jaben Carsey <[email protected]> > >Cc: Ruiyu Ni <[email protected]> > >Contributed-under: TianoCore Contribution Agreement 1.0 > >Signed-off-by: Qiu Shumin <[email protected]> > >--- > > ShellPkg/Library/UefiShellLevel2CommandsLib/Mv.c | 29 +++++++++++++-- > --------- > > 1 file changed, 16 insertions(+), 13 deletions(-) > > > >diff --git a/ShellPkg/Library/UefiShellLevel2CommandsLib/Mv.c > b/ShellPkg/Library/UefiShellLevel2CommandsLib/Mv.c > >index 29efb1c..d02a6ae 100644 > >--- a/ShellPkg/Library/UefiShellLevel2CommandsLib/Mv.c > >+++ b/ShellPkg/Library/UefiShellLevel2CommandsLib/Mv.c > >@@ -483,18 +483,21 @@ ValidateAndMoveFiles( > > Response = *Resp; > > Attr = 0; > > CleanFilePathStr = NULL; > >+ FullCwd = NULL; > > > >- FullCwd = AllocateZeroPool(StrSize(Cwd) + sizeof(CHAR16)); > >- if (FullCwd == NULL) { > >- return SHELL_OUT_OF_RESOURCES; > >- } else { > >- StrCpyS(FullCwd, StrSize(Cwd)/sizeof(CHAR16)+1, Cwd); > >- StrCatS(FullCwd, StrSize(Cwd)/sizeof(CHAR16)+1, L"\\"); > >- } > >+ if (Cwd != NULL) { > >+ FullCwd = AllocateZeroPool(StrSize(Cwd) + sizeof(CHAR16)); > >+ if (FullCwd == NULL) { > >+ return SHELL_OUT_OF_RESOURCES; > >+ } else { > >+ StrCpyS(FullCwd, StrSize(Cwd)/sizeof(CHAR16)+1, Cwd); > >+ StrCatS(FullCwd, StrSize(Cwd)/sizeof(CHAR16)+1, L"\\"); > >+ } > >+ } > > > > Status = ShellLevel2StripQuotes (DestParameter, &CleanFilePathStr); > > if (EFI_ERROR (Status)) { > >- FreePool (FullCwd); > >+ SHELL_FREE_NON_NULL(FullCwd); > > if (Status == EFI_OUT_OF_RESOURCES) { > > return SHELL_OUT_OF_RESOURCES; > > } else { > >@@ -511,7 +514,7 @@ ValidateAndMoveFiles( > > FreePool (CleanFilePathStr); > > > > if (ShellStatus != SHELL_SUCCESS) { > >- FreePool (FullCwd); > >+ SHELL_FREE_NON_NULL (FullCwd); > > return (ShellStatus); > > } > > DestPath = PathCleanUpDirectories(DestPath); > >@@ -526,7 +529,7 @@ ValidateAndMoveFiles( > > SHELL_FREE_NON_NULL(DestPath); > > SHELL_FREE_NON_NULL(HiiOutput); > > SHELL_FREE_NON_NULL(HiiResultOk); > >- FreePool (FullCwd); > >+ SHELL_FREE_NON_NULL(FullCwd); > > return (SHELL_OUT_OF_RESOURCES); > > } > > > >@@ -588,7 +591,7 @@ ValidateAndMoveFiles( > > // > > // indicate to stop everything > > // > >- FreePool(FullCwd); > >+ SHELL_FREE_NON_NULL(FullCwd); > > return (SHELL_ABORTED); > > case ShellPromptResponseAll: > > *Resp = Response; > >@@ -599,7 +602,7 @@ ValidateAndMoveFiles( > > break; > > default: > > FreePool(Response); > >- FreePool(FullCwd); > >+ SHELL_FREE_NON_NULL(FullCwd); > > return SHELL_ABORTED; > > } > > Status = ShellDeleteFileByName(FullDestPath!=NULL? > FullDestPath:DestPath); > >@@ -646,7 +649,7 @@ ValidateAndMoveFiles( > > SHELL_FREE_NON_NULL(DestPath); > > SHELL_FREE_NON_NULL(HiiOutput); > > SHELL_FREE_NON_NULL(HiiResultOk); > >- FreePool (FullCwd); > >+ SHELL_FREE_NON_NULL(FullCwd); > > return (ShellStatus); > > } > > > >-- > >2.7.1.windows.2 > > > >_______________________________________________ > >edk2-devel mailing list > >[email protected] > >https://lists.01.org/mailman/listinfo/edk2-devel _______________________________________________ edk2-devel mailing list [email protected] https://lists.01.org/mailman/listinfo/edk2-devel

