]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ShellPkg/Library/UefiShellLevel2CommandsLib/Cd.c
ShellPkg-Cd: Ensure all valid cd targets are handled properly
[mirror_edk2.git] / ShellPkg / Library / UefiShellLevel2CommandsLib / Cd.c
index 79dd2096f49b3a4765078f9d2730a924c1468db9..1eb7056aee5eaffcaadb9075c3e5aabd86256162 100644 (file)
@@ -4,6 +4,7 @@
   (C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>\r
   (C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR>\r
   Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2018, Dell Technologies. All rights reserved.<BR>\r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
   which accompanies this distribution.  The full text of the license may be found at\r
@@ -261,9 +262,6 @@ ShellCommandRunCd (
 \r
         if (Param1Copy != NULL && IsCurrentFileSystem (Param1Copy, Cwd)) {\r
           Status = ReplaceDriveWithCwd (&Param1Copy,Cwd);\r
-          if (!EFI_ERROR (Status)) {\r
-            Param1Copy = PathCleanUpDirectories (Param1Copy);\r
-          }\r
         } else {\r
           //\r
           // Can't use cd command to change filesystem.\r
@@ -302,13 +300,15 @@ ShellCommandRunCd (
                 StrCatS (TempBuffer, TotalSize / sizeof (CHAR16), Param1Copy);\r
 \r
                 FreePool (Param1Copy);\r
-                Param1Copy = PathCleanUpDirectories (TempBuffer);\r
+                Param1Copy = TempBuffer;\r
+                TempBuffer = NULL;\r
               }\r
             }\r
           }\r
         }\r
 \r
         if (!EFI_ERROR(Status)) {\r
+          Param1Copy = PathCleanUpDirectories (Param1Copy);\r
           Status = ExtractDriveAndPath (Param1Copy, &Drive, &Path);\r
         }\r
 \r