]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ShellPkg: Follow spec to remove the last '\' char in return name of GetCurDir().
authorQiu Shumin <shumin.qiu@intel.com>
Fri, 23 Oct 2015 02:03:20 +0000 (02:03 +0000)
committershenshushi <shenshushi@Edk2>
Fri, 23 Oct 2015 02:03:20 +0000 (02:03 +0000)
In Shell spec 2.1 the return name of EFI_SHELL_PROTOCOL.GetCurDir() is defined as 'fs0:\current-dir' while in current implementation it's 'fs0:\current-dir\'.
To follow spec the patch removed the redundant '\' char.

Since it has been broken for a long time, some codes may depend on the broken behavior.
After this change 'EFI_SHELL_PROTOCOL.GetCurDir()' and 'UefiShellLib.ShellGetCurrentDir()'
will return a current directory string without tailing '\' (fs0:\current-dir), the value of Shell environment variable 'cwd' will become 'fs0:\current-dir' as well.

This patch has updated all the code in EDKII to make them depend on the new behavior.
Developers should check whether 'GetCurDir()' and 'ShellGetCurrentDir' are used in their source code.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Qiu Shumin <shumin.qiu@intel.com>
Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@18653 6f19259b-4bc3-4df7-8a09-765794883524

12 files changed:
ShellPkg/Application/Shell/FileHandleWrappers.c
ShellPkg/Application/Shell/Shell.uni
ShellPkg/Application/Shell/ShellProtocol.c
ShellPkg/Include/Library/ShellLib.h
ShellPkg/Include/Protocol/EfiShell.h
ShellPkg/Library/UefiShellLevel2CommandsLib/Cd.c
ShellPkg/Library/UefiShellLevel2CommandsLib/Cp.c
ShellPkg/Library/UefiShellLevel2CommandsLib/Ls.c
ShellPkg/Library/UefiShellLevel2CommandsLib/Mv.c
ShellPkg/Library/UefiShellLevel2CommandsLib/Rm.c
ShellPkg/Library/UefiShellLevel2CommandsLib/UefiShellLevel2CommandsLib.c
ShellPkg/Library/UefiShellLib/UefiShellLib.c

index 91c35f7cb70a2e1eaf9561847afa94fb74ff4014..64f382718b8509c3225361ce384fa3e06428d748 100644 (file)
@@ -510,6 +510,7 @@ FileInterfaceStdInRead(
           Cwd = ShellInfoObject.NewEfiShellProtocol->GetCurDir(NULL);\r
           if (Cwd != NULL) {\r
             StrnCpyS(TabStr, (*BufferSize)/sizeof(CHAR16), Cwd, (*BufferSize)/sizeof(CHAR16) - 1);\r
+            StrCatS(TabStr, (*BufferSize)/sizeof(CHAR16), L"\\");\r
             if (TabStr[StrLen(TabStr)-1] == L'\\' && *(CurrentString + TabPos) == L'\\' ) {\r
               TabStr[StrLen(TabStr)-1] = CHAR_NULL;\r
             }\r
index 04f001d3870ac3d9f59ebea4617ab5f13e2c4ce9..25cf69966b733e7b2488413361cfab98c2249bfd 100644 (file)
Binary files a/ShellPkg/Application/Shell/Shell.uni and b/ShellPkg/Application/Shell/Shell.uni differ
index 28521ecc154b4e59a3efb6d2ba8b456b719dad66..3a963849f29aef8220004befe43f188cb61726a5 100644 (file)
@@ -532,12 +532,13 @@ EfiShellGetDevicePathFromFilePath(
     if (Cwd == NULL) {\r
       return (NULL);\r
     }\r
-    Size = StrSize(Cwd) + StrSize(Path) - sizeof(CHAR16);\r
+    Size = StrSize(Cwd) + StrSize(Path);\r
     NewPath = AllocateZeroPool(Size);\r
     if (NewPath == NULL) {\r
       return (NULL);\r
     }\r
     StrCpyS(NewPath, Size/sizeof(CHAR16), Cwd);\r
+    StrCatS(NewPath, Size/sizeof(CHAR16), L"\\");\r
     if (*Path == L'\\') {\r
       Path++;\r
       while (PathRemoveLastItem(NewPath)) ;\r
@@ -2495,6 +2496,7 @@ EfiShellOpenFileList(
     CurDir = EfiShellGetCurDir(NULL);\r
     ASSERT((Path2 == NULL && Path2Size == 0) || (Path2 != NULL));\r
     StrnCatGrow(&Path2, &Path2Size, CurDir, 0);\r
+    StrnCatGrow(&Path2, &Path2Size, L"\\", 0);\r
     if (*Path == L'\\') {\r
       Path++;\r
       while (PathRemoveLastItem(Path2)) ;\r
@@ -2796,6 +2798,8 @@ EfiShellSetEnv(
   FileSystemMapping is not NULL, it returns the current directory associated with the\r
   FileSystemMapping. In both cases, the returned name includes the file system\r
   mapping (i.e. fs0:\current-dir).\r
+  \r
+  Note that the current directory string should exclude the tailing backslash character.\r
 \r
   @param FileSystemMapping      A pointer to the file system mapping. If NULL,\r
                                 then the current working directory is returned.\r
@@ -2852,6 +2856,8 @@ EfiShellGetCurDir(
   If the current working directory or the current working file system is changed then the\r
   %cwd% environment variable will be updated\r
 \r
+  Note that the current directory string should exclude the tailing backslash character.\r
+\r
   @param FileSystem             A pointer to the file system's mapped name. If NULL, then the current working\r
                                 directory is changed.\r
   @param Dir                    Points to the NULL-terminated directory on the device specified by FileSystem.\r
@@ -2939,9 +2945,11 @@ EfiShellSetCurDir(
       ASSERT((MapListItem->CurrentDirectoryPath == NULL && Size == 0) || (MapListItem->CurrentDirectoryPath != NULL));\r
       MapListItem->CurrentDirectoryPath = StrnCatGrow(&MapListItem->CurrentDirectoryPath, &Size, DirectoryName, 0);\r
     }\r
-    if ((MapListItem->CurrentDirectoryPath != NULL && MapListItem->CurrentDirectoryPath[StrLen(MapListItem->CurrentDirectoryPath)-1] != L'\\') || (MapListItem->CurrentDirectoryPath == NULL)) {\r
+    if ((MapListItem->CurrentDirectoryPath != NULL && MapListItem->CurrentDirectoryPath[StrLen(MapListItem->CurrentDirectoryPath)-1] == L'\\') || (MapListItem->CurrentDirectoryPath == NULL)) {\r
       ASSERT((MapListItem->CurrentDirectoryPath == NULL && Size == 0) || (MapListItem->CurrentDirectoryPath != NULL));\r
-      MapListItem->CurrentDirectoryPath = StrnCatGrow(&MapListItem->CurrentDirectoryPath, &Size, L"\\", 0);\r
+      if (MapListItem->CurrentDirectoryPath != NULL) {\r
+        MapListItem->CurrentDirectoryPath[StrLen(MapListItem->CurrentDirectoryPath)-1] = CHAR_NULL;\r
+      }\r
     }\r
   } else {\r
     //\r
@@ -2973,9 +2981,9 @@ EfiShellSetCurDir(
       MapListItem->CurrentDirectoryPath = StrnCatGrow(&MapListItem->CurrentDirectoryPath, &Size, L"\\", 0);\r
       ASSERT((MapListItem->CurrentDirectoryPath == NULL && Size == 0) || (MapListItem->CurrentDirectoryPath != NULL));\r
       MapListItem->CurrentDirectoryPath = StrnCatGrow(&MapListItem->CurrentDirectoryPath, &Size, DirectoryName, 0);\r
-      if (MapListItem->CurrentDirectoryPath != NULL && MapListItem->CurrentDirectoryPath[StrLen(MapListItem->CurrentDirectoryPath)-1] != L'\\') {\r
+      if (MapListItem->CurrentDirectoryPath != NULL && MapListItem->CurrentDirectoryPath[StrLen(MapListItem->CurrentDirectoryPath)-1] == L'\\') {\r
         ASSERT((MapListItem->CurrentDirectoryPath == NULL && Size == 0) || (MapListItem->CurrentDirectoryPath != NULL));\r
-        MapListItem->CurrentDirectoryPath = StrnCatGrow(&MapListItem->CurrentDirectoryPath, &Size, L"\\", 0);\r
+        MapListItem->CurrentDirectoryPath[StrLen(MapListItem->CurrentDirectoryPath)-1] = CHAR_NULL;\r
       }\r
     }\r
   }\r
index 23da4eeaf610fb3444015ddeb2397cd1fb46c052..d02d6e9de1f162907b344201fc508dbebf3a033b 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Provides interface to shell functionality for shell commands and applications.\r
 \r
-  Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2006 - 2015, Intel Corporation. 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
@@ -550,6 +550,8 @@ ShellExecute (
   name. If the DeviceName is not NULL, it returns the current directory name\r
   on specified drive.\r
 \r
+  Note that the current directory string should exclude the tailing backslash character.\r
+\r
   @param[in] DeviceName         The name of the file system to get directory on.\r
 \r
   @retval NULL                  The directory does not exist.\r
index 6c1d66a6696d4cbed2436d93b5007aa3fc9166fe..5c7f4f6357266480395ce468605d8e4d032ab0c8 100644 (file)
@@ -2,7 +2,7 @@
   EFI Shell protocol as defined in the UEFI Shell 2.0 specification including errata.\r
 \r
   (C) Copyright 2014 Hewlett-Packard Development Company, L.P.<BR>\r
-  Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2006 - 2015, Intel Corporation. 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
@@ -294,6 +294,8 @@ EFI_STATUS
   FileSystemMapping. In both cases, the returned name includes the file system\r
   mapping (i.e. fs0:\current-dir).\r
 \r
+  Note that the current directory string should exclude the tailing backslash character.\r
+\r
   @param[in] FileSystemMapping  A pointer to the file system mapping. If NULL,\r
                                 then the current working directory is returned.\r
 \r
index 10bc185dbaf6b5c89cc4a8226d5968960b4dea38..19e8e2ff9a79a6ee024c8f3814350119ae680d15 100644 (file)
@@ -2,7 +2,7 @@
   Main file for attrib shell level 2 function.\r
 \r
   (C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR>\r
-  Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2009 - 2015, Intel Corporation. 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
@@ -31,8 +31,10 @@ ShellCommandRunCd (
   EFI_STATUS        Status;\r
   LIST_ENTRY        *Package;\r
   CONST CHAR16      *Directory;\r
+  CHAR16            *Cwd;\r
   CHAR16            *Path;\r
   CHAR16            *Drive;\r
+  UINTN             CwdSize;\r
   UINTN             DriveSize;\r
   CHAR16            *ProblemParam;\r
   SHELL_STATUS      ShellStatus;\r
@@ -121,8 +123,14 @@ ShellCommandRunCd (
             ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_CWD), gShellLevel2HiiHandle, L"cd");  \r
             ShellStatus = SHELL_NOT_FOUND;\r
           } else {\r
-            Drive = GetFullyQualifiedPath(Directory);\r
+            CwdSize = StrSize(Directory) + sizeof(CHAR16);\r
+            Cwd = AllocateZeroPool(CwdSize);\r
+            ASSERT(Cwd!=NULL);\r
+            StrCpyS(Cwd, StrSize(Directory)/sizeof(CHAR16)+1, Directory);\r
+            StrCatS(Cwd, StrSize(Directory)/sizeof(CHAR16)+1, L"\\");\r
+            Drive = GetFullyQualifiedPath(Cwd);\r
             PathRemoveLastItem(Drive);\r
+            FreePool(Cwd);\r
           }\r
           if (ShellStatus == SHELL_SUCCESS && Drive != NULL) {\r
             //\r
@@ -143,8 +151,14 @@ ShellCommandRunCd (
             ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_CWD), gShellLevel2HiiHandle, L"cd");  \r
             ShellStatus = SHELL_NOT_FOUND;\r
           } else {\r
-            Drive = GetFullyQualifiedPath(Directory);\r
-            while (PathRemoveLastItem(Drive)) ;\r
+            CwdSize = StrSize(Directory) + sizeof(CHAR16);\r
+            Cwd = AllocateZeroPool(CwdSize);\r
+            ASSERT(Cwd!=NULL);\r
+            StrCpyS(Cwd, StrSize(Directory)/sizeof(CHAR16)+1, Directory);\r
+            StrCatS(Cwd, StrSize(Directory)/sizeof(CHAR16)+1, L"\\");\r
+            Drive = GetFullyQualifiedPath(Cwd);\r
+            while (PathRemoveLastItem(Drive));\r
+            FreePool(Cwd);\r
           }\r
           if (ShellStatus == SHELL_SUCCESS && Drive != NULL) {\r
             //\r
@@ -166,6 +180,7 @@ ShellCommandRunCd (
           } else {\r
             ASSERT((Drive == NULL && DriveSize == 0) || (Drive != NULL));\r
             Drive = StrnCatGrow(&Drive, &DriveSize, ShellGetCurrentDir(NULL), 0);\r
+            Drive = StrnCatGrow(&Drive, &DriveSize, L"\\", 0);\r
             if (*Param1Copy == L'\\') {\r
               while (PathRemoveLastItem(Drive)) ;\r
               Drive = StrnCatGrow(&Drive, &DriveSize, Param1Copy+1, 0);\r
index deff42e0494e0b0d889e5e744315e37ce19c7973..5cfbc9064f8318670fe7c16807ccb65c15577769 100644 (file)
@@ -360,7 +360,7 @@ ValidateAndCopyFiles(
 \r
     NewSize =  StrSize(CleanFilePathStr);\r
     NewSize += StrSize(Node->FullName);\r
-    NewSize += (Cwd == NULL)? 0 : StrSize(Cwd);\r
+    NewSize += (Cwd == NULL)? 0 : (StrSize(Cwd) + sizeof(CHAR16));\r
     if (NewSize > PathSize) {\r
       PathSize = NewSize;\r
     }\r
@@ -428,6 +428,7 @@ ValidateAndCopyFiles(
         //\r
         if (Cwd != NULL) {\r
           StrCpyS(DestPath, PathSize / sizeof(CHAR16), Cwd);\r
+          StrCatS(DestPath, PathSize / sizeof(CHAR16), L"\\");\r
         } else {\r
           ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_DIR_NF), gShellLevel2HiiHandle, L"cp", CleanFilePathStr);  \r
           FreePool (CleanFilePathStr);\r
@@ -456,6 +457,7 @@ ValidateAndCopyFiles(
          //\r
         if (Cwd != NULL) {\r
           StrCpyS(DestPath, PathSize/sizeof(CHAR16), Cwd);\r
+          StrCatS(DestPath, PathSize/sizeof(CHAR16), L"\\");\r
         } else {\r
           ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_DIR_NF), gShellLevel2HiiHandle, L"cp",  CleanFilePathStr); \r
           FreePool(CleanFilePathStr);\r
@@ -467,6 +469,7 @@ ValidateAndCopyFiles(
       } else if (StrStr(CleanFilePathStr, L":") == NULL) {\r
         if (Cwd != NULL) {\r
           StrCpyS(DestPath, PathSize/sizeof(CHAR16), Cwd);\r
+          StrCatS(DestPath, PathSize/sizeof(CHAR16), L"\\");\r
         } else {\r
           ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_DIR_NF), gShellLevel2HiiHandle, L"cp", CleanFilePathStr);  \r
           FreePool(CleanFilePathStr);\r
@@ -644,6 +647,7 @@ ShellCommandRunCp (
   BOOLEAN             SilentMode;\r
   BOOLEAN             RecursiveMode;\r
   CONST CHAR16        *Cwd;\r
+  CHAR16              *FullCwd;\r
 \r
   ProblemParam        = NULL;\r
   ShellStatus         = SHELL_SUCCESS;\r
@@ -712,7 +716,11 @@ ShellCommandRunCp (
             ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_NF), gShellLevel2HiiHandle, L"cp", ShellCommandLineGetRawValue(Package, 1));  \r
             ShellStatus = SHELL_NOT_FOUND;\r
           } else  {\r
-            ShellStatus = ProcessValidateAndCopyFiles(FileList, Cwd, SilentMode, RecursiveMode);\r
+            FullCwd = AllocateZeroPool(StrSize(Cwd) + sizeof(CHAR16));\r
+            ASSERT (FullCwd != NULL);\r
+            StrCpyS(FullCwd, StrSize(Cwd)/sizeof(CHAR16)+1, Cwd);\r
+            ShellStatus = ProcessValidateAndCopyFiles(FileList, FullCwd, SilentMode, RecursiveMode);\r
+            FreePool(FullCwd);\r
           }\r
         }\r
 \r
index c1e2887aa1fb65c48da32e906939ebcea3a13f76..25bf8ca9e13a124a40ac33bf2293b45e27536f41 100644 (file)
@@ -2,7 +2,7 @@
   Main file for ls shell level 2 function.\r
 \r
   (C) Copyright 2013-2015 Hewlett-Packard Development Company, L.P.<BR>\r
-  Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2009 - 2015, Intel Corporation. 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
@@ -669,6 +669,8 @@ ShellCommandRunLs (
           ASSERT(FullPath == NULL);\r
           StrnCatGrow(&SearchString, NULL, L"*", 0);\r
           StrnCatGrow(&FullPath, NULL, CurDir, 0);\r
+          Size = FullPath != NULL? StrSize(FullPath) : 0;\r
+          StrnCatGrow(&FullPath, &Size, L"\\", 0);\r
         } else {\r
           if (StrStr(PathName, L":") == NULL && gEfiShellProtocol->GetCurDir(NULL) == NULL) {\r
             //\r
@@ -687,6 +689,8 @@ ShellCommandRunLs (
                 ShellCommandLineFreeVarList (Package);\r
                 return SHELL_OUT_OF_RESOURCES;\r
               }\r
+              Size = FullPath != NULL? StrSize(FullPath) : 0;\r
+              StrnCatGrow(&FullPath, &Size, L"\\", 0);\r
             }\r
             StrnCatGrow(&FullPath, &Size, PathName, 0);\r
             if (FullPath == NULL) {\r
index fa6753374394160e6cc91173ccedf7ab44340027..eb7287e48a38c6c67ab9f2192d3c29595d17b6b5 100644 (file)
@@ -467,6 +467,7 @@ ValidateAndMoveFiles(
   CHAR16                    *DestPath;\r
   CHAR16                    *FullDestPath;\r
   CONST CHAR16              *Cwd;\r
+  CHAR16                    *FullCwd;\r
   SHELL_STATUS              ShellStatus;\r
   EFI_SHELL_FILE_INFO       *Node;\r
   VOID                      *Response;\r
@@ -483,8 +484,17 @@ ValidateAndMoveFiles(
   Attr              = 0;\r
   CleanFilePathStr  = NULL;\r
 \r
+  FullCwd = AllocateZeroPool(StrSize(Cwd) + sizeof(CHAR16));\r
+  if (FullCwd == NULL) {\r
+    return SHELL_OUT_OF_RESOURCES;\r
+  } else {\r
+    StrCpyS(FullCwd, StrSize(Cwd)/sizeof(CHAR16)+1, Cwd);\r
+    StrCatS(FullCwd, StrSize(Cwd)/sizeof(CHAR16)+1, L"\\");\r
+  }\r
+\r
   Status = ShellLevel2StripQuotes (DestParameter, &CleanFilePathStr);\r
   if (EFI_ERROR (Status)) {\r
+    FreePool (FullCwd);\r
     if (Status == EFI_OUT_OF_RESOURCES) {\r
       return SHELL_OUT_OF_RESOURCES;\r
     } else {\r
@@ -497,14 +507,16 @@ ValidateAndMoveFiles(
   //\r
   // Get and validate the destination location\r
   //\r
-  ShellStatus = GetDestinationLocation(CleanFilePathStr, &DestPath, Cwd, (BOOLEAN)(FileList->Link.ForwardLink == FileList->Link.BackLink), &Attr);\r
+  ShellStatus = GetDestinationLocation(CleanFilePathStr, &DestPath, FullCwd, (BOOLEAN)(FileList->Link.ForwardLink == FileList->Link.BackLink), &Attr);\r
   FreePool (CleanFilePathStr);\r
 \r
   if (ShellStatus != SHELL_SUCCESS) {\r
+    FreePool (FullCwd);\r
     return (ShellStatus);\r
   }\r
   DestPath = PathCleanUpDirectories(DestPath);\r
   if (DestPath == NULL) {\r
+    FreePool (FullCwd);\r
     return (SHELL_OUT_OF_RESOURCES);\r
   }\r
 \r
@@ -514,6 +526,7 @@ ValidateAndMoveFiles(
     SHELL_FREE_NON_NULL(DestPath);\r
     SHELL_FREE_NON_NULL(HiiOutput);\r
     SHELL_FREE_NON_NULL(HiiResultOk);\r
+    FreePool (FullCwd);\r
     return (SHELL_OUT_OF_RESOURCES);\r
   }\r
 \r
@@ -551,7 +564,7 @@ ValidateAndMoveFiles(
     //\r
     // Validate that the move is valid\r
     //\r
-    if (!IsValidMove(Node->FullName, Cwd, FullDestPath!=NULL? FullDestPath:DestPath, Node->Info->Attribute, Attr, Node->Status)) {\r
+    if (!IsValidMove(Node->FullName, FullCwd, FullDestPath!=NULL? FullDestPath:DestPath, Node->Info->Attribute, Attr, Node->Status)) {\r
       ShellStatus = SHELL_INVALID_PARAMETER;\r
       continue;\r
     }\r
@@ -575,6 +588,7 @@ ValidateAndMoveFiles(
           //\r
           // indicate to stop everything\r
           //\r
+          FreePool(FullCwd);\r
           return (SHELL_ABORTED);\r
         case ShellPromptResponseAll:\r
           *Resp = Response;\r
@@ -585,12 +599,13 @@ ValidateAndMoveFiles(
           break;\r
         default:\r
           FreePool(Response);\r
+          FreePool(FullCwd);\r
           return SHELL_ABORTED;\r
       }\r
       Status = ShellDeleteFileByName(FullDestPath!=NULL? FullDestPath:DestPath);\r
     }\r
 \r
-    if (IsBetweenFileSystem(Node->FullName, Cwd, DestPath)) {\r
+    if (IsBetweenFileSystem(Node->FullName, FullCwd, DestPath)) {\r
       while (FullDestPath == NULL && DestPath != NULL && DestPath[0] != CHAR_NULL && DestPath[StrLen(DestPath) - 1] == L'\\') {\r
         DestPath[StrLen(DestPath) - 1] = CHAR_NULL;\r
       }\r
@@ -631,6 +646,7 @@ ValidateAndMoveFiles(
   SHELL_FREE_NON_NULL(DestPath);\r
   SHELL_FREE_NON_NULL(HiiOutput);\r
   SHELL_FREE_NON_NULL(HiiResultOk);\r
+  FreePool (FullCwd);\r
   return (ShellStatus);\r
 }\r
 \r
@@ -650,6 +666,8 @@ ShellCommandRunMv (
   EFI_STATUS          Status;\r
   LIST_ENTRY          *Package;\r
   CHAR16              *ProblemParam;\r
+  CHAR16              *Cwd;\r
+  UINTN               CwdSize;\r
   SHELL_STATUS        ShellStatus;\r
   UINTN               ParamCount;\r
   UINTN               LoopCounter;\r
@@ -713,7 +731,13 @@ ShellCommandRunMv (
             //\r
             // ValidateAndMoveFiles will report errors to the screen itself\r
             //\r
-            ShellStatus = ValidateAndMoveFiles(FileList, &Response, ShellGetCurrentDir(NULL));\r
+            CwdSize = StrSize(ShellGetCurrentDir(NULL)) + 1;\r
+            Cwd = AllocateZeroPool(CwdSize);\r
+            ASSERT (Cwd != NULL);\r
+            StrCpyS(Cwd, CwdSize/sizeof(CHAR16), ShellGetCurrentDir(NULL));\r
+            StrCatS(Cwd, CwdSize/sizeof(CHAR16), L"\\");\r
+            ShellStatus = ValidateAndMoveFiles(FileList, &Response, Cwd);\r
+            FreePool(Cwd);\r
           }\r
         }\r
 \r
index ed9940d82704e9bc6b4eee66f18e1da5990f3e6b..0b23fba150815204e2180ac5e8ba9ca7ff4fee9e 100644 (file)
@@ -231,7 +231,9 @@ IsValidDeleteTarget(
   Pattern       = NULL;\r
   SearchString  = NULL;\r
   Size          = 0;\r
-  Pattern       = StrnCatGrow(&Pattern     , NULL, TempLocation  , 0);\r
+  Pattern       = StrnCatGrow(&Pattern, &Size, TempLocation  , 0);\r
+  Pattern       = StrnCatGrow(&Pattern, &Size, L"\\"  , 0);\r
+  Size = 0;\r
   SearchString  = StrnCatGrow(&SearchString, &Size, Node->FullName, 0);\r
   if (!EFI_ERROR(ShellIsDirectory(SearchString))) {\r
     SearchString  = StrnCatGrow(&SearchString, &Size, L"\\", 0);\r
index 4ac7e67007f8e5b6e432ce5684d2c7c113e93944..0dafb19969c5af64d09e3a66d74a6a9533920693 100644 (file)
@@ -22,7 +22,7 @@
   * functions are non-interactive only\r
 \r
   Copyright (c) 2014 Hewlett-Packard Development Company, L.P.\r
-  Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2009 - 2015, Intel Corporation. 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
@@ -188,6 +188,7 @@ GetFullyQualifiedPath(
   if (StrStr(Path, L":") == NULL) {\r
     CurDir = gEfiShellProtocol->GetCurDir(NULL);\r
     StrnCatGrow(&PathToReturn, &Size, CurDir, 0);\r
+    StrnCatGrow(&PathToReturn, &Size, L"\\", 0);\r
     if (*Path == L'\\') {\r
       Path++;\r
     }\r
index 6e0f61130ff463f3bc2860245eb0944961770863..44ac382980c0f3edbb8e3dcd16e07f5a5279b892 100644 (file)
@@ -1276,6 +1276,8 @@ ShellExecute (
   name. If the DeviceName is not NULL, it returns the current directory name\r
   on specified drive.\r
 \r
+  Note that the current directory string should exclude the tailing backslash character.\r
+\r
   @param DeviceName             the name of the drive to get directory on\r
 \r
   @retval NULL                  the directory does not exist\r
@@ -1708,13 +1710,14 @@ ShellFindFilePath (
 \r
   Path = ShellGetEnvironmentVariable(L"cwd");\r
   if (Path != NULL) {\r
-    Size = StrSize(Path);\r
+    Size = StrSize(Path) + sizeof(CHAR16);\r
     Size += StrSize(FileName);\r
     TestPath = AllocateZeroPool(Size);\r
     if (TestPath == NULL) {\r
       return (NULL);\r
     }\r
     StrCpyS(TestPath, Size/sizeof(CHAR16), Path);\r
+    StrCatS(TestPath, Size/sizeof(CHAR16), L"\\");\r
     StrCatS(TestPath, Size/sizeof(CHAR16), FileName);\r
     Status = ShellOpenFileByName(TestPath, &Handle, EFI_FILE_MODE_READ, 0);\r
     if (!EFI_ERROR(Status)){\r