Qiu Shumin
2015-06-30 01:54:39 UTC
When doing the mv we should check whether source is 'above' dest on file path tree. This patch make the check logic more precise.
Signed-off-by: Qiu Shumin <***@intel.com>
Reviewed-by: Jaben Carsey <***@intel.com>
---
ShellPkg/Library/UefiShellLevel2CommandsLib/Mv.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/ShellPkg/Library/UefiShellLevel2CommandsLib/Mv.c b/ShellPkg/Library/UefiShellLevel2CommandsLib/Mv.c
index c025ceb..cf6d3a5 100644
--- a/ShellPkg/Library/UefiShellLevel2CommandsLib/Mv.c
+++ b/ShellPkg/Library/UefiShellLevel2CommandsLib/Mv.c
@@ -2,7 +2,7 @@
Main file for mv shell level 2 function.
(C) Copyright 2013-2015 Hewlett-Packard Development Company, L.P.<BR>
- Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2009 - 2015, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -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);
Signed-off-by: Qiu Shumin <***@intel.com>
Reviewed-by: Jaben Carsey <***@intel.com>
---
ShellPkg/Library/UefiShellLevel2CommandsLib/Mv.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/ShellPkg/Library/UefiShellLevel2CommandsLib/Mv.c b/ShellPkg/Library/UefiShellLevel2CommandsLib/Mv.c
index c025ceb..cf6d3a5 100644
--- a/ShellPkg/Library/UefiShellLevel2CommandsLib/Mv.c
+++ b/ShellPkg/Library/UefiShellLevel2CommandsLib/Mv.c
@@ -2,7 +2,7 @@
Main file for mv shell level 2 function.
(C) Copyright 2013-2015 Hewlett-Packard Development Company, L.P.<BR>
- Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2009 - 2015, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -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);
--
1.9.5.msysgit.1
1.9.5.msysgit.1