]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ShellPkg: Refine the code logic of mv.c.
authorQiu Shumin <shumin.qiu@intel.com>
Wed, 1 Jul 2015 01:46:20 +0000 (01:46 +0000)
committershenshushi <shenshushi@Edk2>
Wed, 1 Jul 2015 01:46:20 +0000 (01:46 +0000)
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 <shumin.qiu@intel.com>
Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
Reviewed-by: Samer El-Haj-Mahmoud <elhaj@hp.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@17750 6f19259b-4bc3-4df7-8a09-765794883524

ShellPkg/Library/UefiShellLevel2CommandsLib/Mv.c

index 40ba00b4934c31da8881b3936bdac46d24ceded7..fa6753374394160e6cc91173ccedf7ab44340027 100644 (file)
@@ -128,9 +128,11 @@ IsValidMove(
   //\r
   // If they're the same, or if source is "above" dest on file path tree\r
   //\r
-  if ( StringNoCaseCompare (&DestPathWalker, &SourcePath) == 0 \r
-    || StrStr(DestPathWalker, SourcePath) == DestPathWalker \r
-    ) {\r
+  if ( StringNoCaseCompare (&DestPathWalker, &SourcePath) == 0 ||\r
+       ((StrStr(DestPathWalker, SourcePath) == DestPathWalker) && \r
+        (DestPathWalker[StrLen(SourcePath)] == '\\')\r
+       )\r
+     ) {\r
     ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MV_INV_SUB), gShellLevel2HiiHandle);\r
     FreePool(DestPathCopy);\r
     return (FALSE);\r