On 10/4/2018 11:03 PM, jim.dai...@dell.com wrote:
MdePkg-BaseLib: Fix PathCleanUpDirectories() error involving "\..\.."

The loop that removes "xxxx\..\" errs when multiple "\.." sequences are
in the path.  Before this change the code would modify a path like
"FS0:\efi\tools\..\.." to "FS0:\efi\\.." and then to "FS0:\efi\", but
the correct path is "FS0:\".

You can test the effect of this change in the shell by setting the
current directory to something like FS0:\efi\boot and then executing
the command "ls ..\..".  Before the change you will see the files in
the FS0:\efi directory; after the change, you will see the files in
the root directory of FS0:.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jim Dailey <jim_dai...@dell.com>
---
  MdePkg/Library/BaseLib/FilePaths.c | 5 ++++-
  1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/MdePkg/Library/BaseLib/FilePaths.c 
b/MdePkg/Library/BaseLib/FilePaths.c
index d6f3758ecb..5d3de01894 100644
--- a/MdePkg/Library/BaseLib/FilePaths.c
+++ b/MdePkg/Library/BaseLib/FilePaths.c
@@ -2,6 +2,7 @@
    Defines file-path manipulation functions.
Copyright (c) 2011 - 2017, Intel Corporation. All rights reserved.<BR>
+  Copyright (c) 2018, Dell Technologies. 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
@@ -103,7 +104,9 @@ PathCleanUpDirectories(
          ) {
      *(TempString + 1) = CHAR_NULL;
      PathRemoveLastItem(Path);
-    CopyMem (Path + StrLen (Path), TempString + 3, StrSize (TempString + 3));
+    if (*(TempString + 3)) {
+      CopyMem (Path + StrLen (Path), TempString + 4, StrSize (TempString + 4));
+    }
    }
//

Jim,
Are you fixing a corner case bug introduced by following commit:

> SHA-1: bb99e3282c9e69fbd6365d117c58d15589e34c5d
* MdePkg/BaseLib: Fix PathCleanUpDirectories to correctly handle "\.\"

> The old code incorrectly cleans path like "fs0:\abc\.\.." to
> "fs0:\abc", instead of "fs0:\"

> The patch fixes this bug.


If yes, can you mention the above commit in your commit message?


--
Thanks,
Ray
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel

Reply via email to