From 2ce8ce9b064c0058964cb35ddc7272059fb7663c Mon Sep 17 00:00:00 2001 From: Qiu Shumin Date: Wed, 1 Jul 2015 01:46:20 +0000 Subject: ShellPkg: Refine the code logic of mv.c. When doing the mv we should check whether source is 'above' dest on file path tree. This patch make the check logic more precise. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Qiu Shumin Reviewed-by: Jaben Carsey Reviewed-by: Samer El-Haj-Mahmoud git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@17750 6f19259b-4bc3-4df7-8a09-765794883524 --- ShellPkg/Library/UefiShellLevel2CommandsLib/Mv.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'ShellPkg/Library/UefiShellLevel2CommandsLib') diff --git a/ShellPkg/Library/UefiShellLevel2CommandsLib/Mv.c b/ShellPkg/Library/UefiShellLevel2CommandsLib/Mv.c index 40ba00b493..fa67533743 100644 --- a/ShellPkg/Library/UefiShellLevel2CommandsLib/Mv.c +++ b/ShellPkg/Library/UefiShellLevel2CommandsLib/Mv.c @@ -128,9 +128,11 @@ IsValidMove( // // If they're the same, or if source is "above" dest on file path tree // - if ( StringNoCaseCompare (&DestPathWalker, &SourcePath) == 0 - || StrStr(DestPathWalker, SourcePath) == DestPathWalker - ) { + if ( StringNoCaseCompare (&DestPathWalker, &SourcePath) == 0 || + ((StrStr(DestPathWalker, SourcePath) == DestPathWalker) && + (DestPathWalker[StrLen(SourcePath)] == '\\') + ) + ) { ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MV_INV_SUB), gShellLevel2HiiHandle); FreePool(DestPathCopy); return (FALSE); -- cgit v1.2.3