Revision: 19395
http://sourceforge.net/p/edk2/code/19395
Author: vanjeff
Date: 2015-12-18 07:30:21 +0000 (Fri, 18 Dec 2015)
Log Message:
-----------
ShellPkg: Follow spec to remove the last '\' char in return name of GetCurDir().
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.
(Sync patch r18653 from main trunk.)
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Qiu Shumin <[email protected]>
Reviewed-by: Jaben Carsey <[email protected]>
Revision Links:
--------------
http://sourceforge.net/p/edk2/code/18653
Modified Paths:
--------------
branches/UDK2015/ShellPkg/Application/Shell/FileHandleWrappers.c
branches/UDK2015/ShellPkg/Application/Shell/Shell.uni
branches/UDK2015/ShellPkg/Application/Shell/ShellProtocol.c
branches/UDK2015/ShellPkg/Include/Library/ShellLib.h
branches/UDK2015/ShellPkg/Include/Protocol/EfiShell.h
branches/UDK2015/ShellPkg/Library/UefiShellLevel2CommandsLib/Cd.c
branches/UDK2015/ShellPkg/Library/UefiShellLevel2CommandsLib/Cp.c
branches/UDK2015/ShellPkg/Library/UefiShellLevel2CommandsLib/Ls.c
branches/UDK2015/ShellPkg/Library/UefiShellLevel2CommandsLib/Mv.c
branches/UDK2015/ShellPkg/Library/UefiShellLevel2CommandsLib/Rm.c
branches/UDK2015/ShellPkg/Library/UefiShellLevel2CommandsLib/UefiShellLevel2CommandsLib.c
branches/UDK2015/ShellPkg/Library/UefiShellLib/UefiShellLib.c
Modified: branches/UDK2015/ShellPkg/Application/Shell/FileHandleWrappers.c
===================================================================
--- branches/UDK2015/ShellPkg/Application/Shell/FileHandleWrappers.c
2015-12-18 07:29:05 UTC (rev 19394)
+++ branches/UDK2015/ShellPkg/Application/Shell/FileHandleWrappers.c
2015-12-18 07:30:21 UTC (rev 19395)
@@ -510,6 +510,7 @@
Cwd = ShellInfoObject.NewEfiShellProtocol->GetCurDir(NULL);
if (Cwd != NULL) {
StrnCpyS(TabStr, (*BufferSize)/sizeof(CHAR16), Cwd,
(*BufferSize)/sizeof(CHAR16) - 1);
+ StrCatS(TabStr, (*BufferSize)/sizeof(CHAR16), L"\\");
if (TabStr[StrLen(TabStr)-1] == L'\\' && *(CurrentString + TabPos)
== L'\\' ) {
TabStr[StrLen(TabStr)-1] = CHAR_NULL;
}
Modified: branches/UDK2015/ShellPkg/Application/Shell/Shell.uni
===================================================================
--- branches/UDK2015/ShellPkg/Application/Shell/Shell.uni 2015-12-18
07:29:05 UTC (rev 19394)
+++ branches/UDK2015/ShellPkg/Application/Shell/Shell.uni 2015-12-18
07:30:21 UTC (rev 19395)
@@ -4,7 +4,7 @@
- @@ -54,7 +54,7 @@
-
Modified: branches/UDK2015/ShellPkg/Application/Shell/ShellProtocol.c
===================================================================
--- branches/UDK2015/ShellPkg/Application/Shell/ShellProtocol.c 2015-12-18
07:29:05 UTC (rev 19394)
+++ branches/UDK2015/ShellPkg/Application/Shell/ShellProtocol.c 2015-12-18
07:30:21 UTC (rev 19395)
@@ -532,12 +532,13 @@
if (Cwd == NULL) {
return (NULL);
}
- Size = StrSize(Cwd) + StrSize(Path) - sizeof(CHAR16);
+ Size = StrSize(Cwd) + StrSize(Path);
NewPath = AllocateZeroPool(Size);
if (NewPath == NULL) {
return (NULL);
}
StrCpyS(NewPath, Size/sizeof(CHAR16), Cwd);
+ StrCatS(NewPath, Size/sizeof(CHAR16), L"\\");
if (*Path == L'\\') {
Path++;
while (PathRemoveLastItem(NewPath)) ;
@@ -2495,6 +2496,7 @@
CurDir = EfiShellGetCurDir(NULL);
ASSERT((Path2 == NULL && Path2Size == 0) || (Path2 != NULL));
StrnCatGrow(&Path2, &Path2Size, CurDir, 0);
+ StrnCatGrow(&Path2, &Path2Size, L"\\", 0);
if (*Path == L'\\') {
Path++;
while (PathRemoveLastItem(Path2)) ;
@@ -2796,6 +2798,8 @@
FileSystemMapping is not NULL, it returns the current directory associated
with the
FileSystemMapping. In both cases, the returned name includes the file system
mapping (i.e. fs0:\current-dir).
+
+ Note that the current directory string should exclude the tailing backslash
character.
@param FileSystemMapping A pointer to the file system mapping. If NULL,
then the current working directory is returned.
@@ -2852,6 +2856,8 @@
If the current working directory or the current working file system is
changed then the
%cwd% environment variable will be updated
+ Note that the current directory string should exclude the tailing backslash
character.
+
@param FileSystem A pointer to the file system's mapped name. If
NULL, then the current working
directory is changed.
@param Dir Points to the NULL-terminated directory on the
device specified by FileSystem.
@@ -2939,9 +2945,11 @@
ASSERT((MapListItem->CurrentDirectoryPath == NULL && Size == 0) ||
(MapListItem->CurrentDirectoryPath != NULL));
MapListItem->CurrentDirectoryPath =
StrnCatGrow(&MapListItem->CurrentDirectoryPath, &Size, DirectoryName, 0);
}
- if ((MapListItem->CurrentDirectoryPath != NULL &&
MapListItem->CurrentDirectoryPath[StrLen(MapListItem->CurrentDirectoryPath)-1]
!= L'\\') || (MapListItem->CurrentDirectoryPath == NULL)) {
+ if ((MapListItem->CurrentDirectoryPath != NULL &&
MapListItem->CurrentDirectoryPath[StrLen(MapListItem->CurrentDirectoryPath)-1]
== L'\\') || (MapListItem->CurrentDirectoryPath == NULL)) {
ASSERT((MapListItem->CurrentDirectoryPath == NULL && Size == 0) ||
(MapListItem->CurrentDirectoryPath != NULL));
- MapListItem->CurrentDirectoryPath =
StrnCatGrow(&MapListItem->CurrentDirectoryPath, &Size, L"\\", 0);
+ if (MapListItem->CurrentDirectoryPath != NULL) {
+
MapListItem->CurrentDirectoryPath[StrLen(MapListItem->CurrentDirectoryPath)-1]
= CHAR_NULL;
+ }
}
} else {
//
@@ -2973,9 +2981,9 @@
MapListItem->CurrentDirectoryPath =
StrnCatGrow(&MapListItem->CurrentDirectoryPath, &Size, L"\\", 0);
ASSERT((MapListItem->CurrentDirectoryPath == NULL && Size == 0) ||
(MapListItem->CurrentDirectoryPath != NULL));
MapListItem->CurrentDirectoryPath =
StrnCatGrow(&MapListItem->CurrentDirectoryPath, &Size, DirectoryName, 0);
- if (MapListItem->CurrentDirectoryPath != NULL &&
MapListItem->CurrentDirectoryPath[StrLen(MapListItem->CurrentDirectoryPath)-1]
!= L'\\') {
+ if (MapListItem->CurrentDirectoryPath != NULL &&
MapListItem->CurrentDirectoryPath[StrLen(MapListItem->CurrentDirectoryPath)-1]
== L'\\') {
ASSERT((MapListItem->CurrentDirectoryPath == NULL && Size == 0) ||
(MapListItem->CurrentDirectoryPath != NULL));
- MapListItem->CurrentDirectoryPath =
StrnCatGrow(&MapListItem->CurrentDirectoryPath, &Size, L"\\", 0);
+
MapListItem->CurrentDirectoryPath[StrLen(MapListItem->CurrentDirectoryPath)-1]
= CHAR_NULL;
}
}
}
Modified: branches/UDK2015/ShellPkg/Include/Library/ShellLib.h
===================================================================
--- branches/UDK2015/ShellPkg/Include/Library/ShellLib.h 2015-12-18
07:29:05 UTC (rev 19394)
+++ branches/UDK2015/ShellPkg/Include/Library/ShellLib.h 2015-12-18
07:30:21 UTC (rev 19395)
@@ -1,7 +1,7 @@
/** @file
Provides interface to shell functionality for shell commands and
applications.
- Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2006 - 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
@@ -550,6 +550,8 @@
name. If the DeviceName is not NULL, it returns the current directory name
on specified drive.
+ Note that the current directory string should exclude the tailing backslash
character.
+
@param[in] DeviceName The name of the file system to get directory
on.
@retval NULL The directory does not exist.
Modified: branches/UDK2015/ShellPkg/Include/Protocol/EfiShell.h
===================================================================
--- branches/UDK2015/ShellPkg/Include/Protocol/EfiShell.h 2015-12-18
07:29:05 UTC (rev 19394)
+++ branches/UDK2015/ShellPkg/Include/Protocol/EfiShell.h 2015-12-18
07:30:21 UTC (rev 19395)
@@ -2,7 +2,7 @@
EFI Shell protocol as defined in the UEFI Shell 2.0 specification including
errata.
(C) Copyright 2014 Hewlett-Packard Development Company, L.P.<BR>
- Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2006 - 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
@@ -294,6 +294,8 @@
FileSystemMapping. In both cases, the returned name includes the file system
mapping (i.e. fs0:\current-dir).
+ Note that the current directory string should exclude the tailing backslash
character.
+
@param[in] FileSystemMapping A pointer to the file system mapping. If NULL,
then the current working directory is returned.
Modified: branches/UDK2015/ShellPkg/Library/UefiShellLevel2CommandsLib/Cd.c
===================================================================
--- branches/UDK2015/ShellPkg/Library/UefiShellLevel2CommandsLib/Cd.c
2015-12-18 07:29:05 UTC (rev 19394)
+++ branches/UDK2015/ShellPkg/Library/UefiShellLevel2CommandsLib/Cd.c
2015-12-18 07:30:21 UTC (rev 19395)
@@ -2,7 +2,7 @@
Main file for attrib shell level 2 function.
(C) Copyright 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
@@ -31,8 +31,10 @@
EFI_STATUS Status;
LIST_ENTRY *Package;
CONST CHAR16 *Directory;
+ CHAR16 *Cwd;
CHAR16 *Path;
CHAR16 *Drive;
+ UINTN CwdSize;
UINTN DriveSize;
CHAR16 *ProblemParam;
SHELL_STATUS ShellStatus;
@@ -121,8 +123,14 @@
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_CWD),
gShellLevel2HiiHandle, L"cd");
ShellStatus = SHELL_NOT_FOUND;
} else {
- Drive = GetFullyQualifiedPath(Directory);
+ CwdSize = StrSize(Directory) + sizeof(CHAR16);
+ Cwd = AllocateZeroPool(CwdSize);
+ ASSERT(Cwd!=NULL);
+ StrCpyS(Cwd, StrSize(Directory)/sizeof(CHAR16)+1, Directory);
+ StrCatS(Cwd, StrSize(Directory)/sizeof(CHAR16)+1, L"\\");
+ Drive = GetFullyQualifiedPath(Cwd);
PathRemoveLastItem(Drive);
+ FreePool(Cwd);
}
if (ShellStatus == SHELL_SUCCESS && Drive != NULL) {
//
@@ -143,8 +151,14 @@
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_CWD),
gShellLevel2HiiHandle, L"cd");
ShellStatus = SHELL_NOT_FOUND;
} else {
- Drive = GetFullyQualifiedPath(Directory);
- while (PathRemoveLastItem(Drive)) ;
+ CwdSize = StrSize(Directory) + sizeof(CHAR16);
+ Cwd = AllocateZeroPool(CwdSize);
+ ASSERT(Cwd!=NULL);
+ StrCpyS(Cwd, StrSize(Directory)/sizeof(CHAR16)+1, Directory);
+ StrCatS(Cwd, StrSize(Directory)/sizeof(CHAR16)+1, L"\\");
+ Drive = GetFullyQualifiedPath(Cwd);
+ while (PathRemoveLastItem(Drive));
+ FreePool(Cwd);
}
if (ShellStatus == SHELL_SUCCESS && Drive != NULL) {
//
@@ -166,6 +180,7 @@
} else {
ASSERT((Drive == NULL && DriveSize == 0) || (Drive != NULL));
Drive = StrnCatGrow(&Drive, &DriveSize, ShellGetCurrentDir(NULL),
0);
+ Drive = StrnCatGrow(&Drive, &DriveSize, L"\\", 0);
if (*Param1Copy == L'\\') {
while (PathRemoveLastItem(Drive)) ;
Drive = StrnCatGrow(&Drive, &DriveSize, Param1Copy+1, 0);
Modified: branches/UDK2015/ShellPkg/Library/UefiShellLevel2CommandsLib/Cp.c
===================================================================
--- branches/UDK2015/ShellPkg/Library/UefiShellLevel2CommandsLib/Cp.c
2015-12-18 07:29:05 UTC (rev 19394)
+++ branches/UDK2015/ShellPkg/Library/UefiShellLevel2CommandsLib/Cp.c
2015-12-18 07:30:21 UTC (rev 19395)
@@ -360,7 +360,7 @@
NewSize = StrSize(CleanFilePathStr);
NewSize += StrSize(Node->FullName);
- NewSize += (Cwd == NULL)? 0 : StrSize(Cwd);
+ NewSize += (Cwd == NULL)? 0 : (StrSize(Cwd) + sizeof(CHAR16));
if (NewSize > PathSize) {
PathSize = NewSize;
}
@@ -428,6 +428,7 @@
//
if (Cwd != NULL) {
StrCpyS(DestPath, PathSize / sizeof(CHAR16), Cwd);
+ StrCatS(DestPath, PathSize / sizeof(CHAR16), L"\\");
} else {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_DIR_NF),
gShellLevel2HiiHandle, L"cp", CleanFilePathStr);
FreePool (CleanFilePathStr);
@@ -456,6 +457,7 @@
//
if (Cwd != NULL) {
StrCpyS(DestPath, PathSize/sizeof(CHAR16), Cwd);
+ StrCatS(DestPath, PathSize/sizeof(CHAR16), L"\\");
} else {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_DIR_NF),
gShellLevel2HiiHandle, L"cp", CleanFilePathStr);
FreePool(CleanFilePathStr);
@@ -467,6 +469,7 @@
} else if (StrStr(CleanFilePathStr, L":") == NULL) {
if (Cwd != NULL) {
StrCpyS(DestPath, PathSize/sizeof(CHAR16), Cwd);
+ StrCatS(DestPath, PathSize/sizeof(CHAR16), L"\\");
} else {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_DIR_NF),
gShellLevel2HiiHandle, L"cp", CleanFilePathStr);
FreePool(CleanFilePathStr);
@@ -644,6 +647,7 @@
BOOLEAN SilentMode;
BOOLEAN RecursiveMode;
CONST CHAR16 *Cwd;
+ CHAR16 *FullCwd;
ProblemParam = NULL;
ShellStatus = SHELL_SUCCESS;
@@ -712,7 +716,11 @@
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_NF),
gShellLevel2HiiHandle, L"cp", ShellCommandLineGetRawValue(Package, 1));
ShellStatus = SHELL_NOT_FOUND;
} else {
- ShellStatus = ProcessValidateAndCopyFiles(FileList, Cwd,
SilentMode, RecursiveMode);
+ FullCwd = AllocateZeroPool(StrSize(Cwd) + sizeof(CHAR16));
+ ASSERT (FullCwd != NULL);
+ StrCpyS(FullCwd, StrSize(Cwd)/sizeof(CHAR16)+1, Cwd);
+ ShellStatus = ProcessValidateAndCopyFiles(FileList, FullCwd,
SilentMode, RecursiveMode);
+ FreePool(FullCwd);
}
}
Modified: branches/UDK2015/ShellPkg/Library/UefiShellLevel2CommandsLib/Ls.c
===================================================================
--- branches/UDK2015/ShellPkg/Library/UefiShellLevel2CommandsLib/Ls.c
2015-12-18 07:29:05 UTC (rev 19394)
+++ branches/UDK2015/ShellPkg/Library/UefiShellLevel2CommandsLib/Ls.c
2015-12-18 07:30:21 UTC (rev 19395)
@@ -2,7 +2,7 @@
Main file for ls 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
@@ -669,6 +669,8 @@
ASSERT(FullPath == NULL);
StrnCatGrow(&SearchString, NULL, L"*", 0);
StrnCatGrow(&FullPath, NULL, CurDir, 0);
+ Size = FullPath != NULL? StrSize(FullPath) : 0;
+ StrnCatGrow(&FullPath, &Size, L"\\", 0);
} else {
if (StrStr(PathName, L":") == NULL &&
gEfiShellProtocol->GetCurDir(NULL) == NULL) {
//
@@ -687,6 +689,8 @@
ShellCommandLineFreeVarList (Package);
return SHELL_OUT_OF_RESOURCES;
}
+ Size = FullPath != NULL? StrSize(FullPath) : 0;
+ StrnCatGrow(&FullPath, &Size, L"\\", 0);
}
StrnCatGrow(&FullPath, &Size, PathName, 0);
if (FullPath == NULL) {
Modified: branches/UDK2015/ShellPkg/Library/UefiShellLevel2CommandsLib/Mv.c
===================================================================
--- branches/UDK2015/ShellPkg/Library/UefiShellLevel2CommandsLib/Mv.c
2015-12-18 07:29:05 UTC (rev 19394)
+++ branches/UDK2015/ShellPkg/Library/UefiShellLevel2CommandsLib/Mv.c
2015-12-18 07:30:21 UTC (rev 19395)
@@ -467,6 +467,7 @@
CHAR16 *DestPath;
CHAR16 *FullDestPath;
CONST CHAR16 *Cwd;
+ CHAR16 *FullCwd;
SHELL_STATUS ShellStatus;
EFI_SHELL_FILE_INFO *Node;
VOID *Response;
@@ -483,8 +484,17 @@
Attr = 0;
CleanFilePathStr = NULL;
+ FullCwd = AllocateZeroPool(StrSize(Cwd) + sizeof(CHAR16));
+ if (FullCwd == NULL) {
+ return SHELL_OUT_OF_RESOURCES;
+ } else {
+ StrCpyS(FullCwd, StrSize(Cwd)/sizeof(CHAR16)+1, Cwd);
+ StrCatS(FullCwd, StrSize(Cwd)/sizeof(CHAR16)+1, L"\\");
+ }
+
Status = ShellLevel2StripQuotes (DestParameter, &CleanFilePathStr);
if (EFI_ERROR (Status)) {
+ FreePool (FullCwd);
if (Status == EFI_OUT_OF_RESOURCES) {
return SHELL_OUT_OF_RESOURCES;
} else {
@@ -497,14 +507,16 @@
//
// Get and validate the destination location
//
- ShellStatus = GetDestinationLocation(CleanFilePathStr, &DestPath, Cwd,
(BOOLEAN)(FileList->Link.ForwardLink == FileList->Link.BackLink), &Attr);
+ ShellStatus = GetDestinationLocation(CleanFilePathStr, &DestPath, FullCwd,
(BOOLEAN)(FileList->Link.ForwardLink == FileList->Link.BackLink), &Attr);
FreePool (CleanFilePathStr);
if (ShellStatus != SHELL_SUCCESS) {
+ FreePool (FullCwd);
return (ShellStatus);
}
DestPath = PathCleanUpDirectories(DestPath);
if (DestPath == NULL) {
+ FreePool (FullCwd);
return (SHELL_OUT_OF_RESOURCES);
}
@@ -514,6 +526,7 @@
SHELL_FREE_NON_NULL(DestPath);
SHELL_FREE_NON_NULL(HiiOutput);
SHELL_FREE_NON_NULL(HiiResultOk);
+ FreePool (FullCwd);
return (SHELL_OUT_OF_RESOURCES);
}
@@ -551,7 +564,7 @@
//
// Validate that the move is valid
//
- if (!IsValidMove(Node->FullName, Cwd, FullDestPath!=NULL?
FullDestPath:DestPath, Node->Info->Attribute, Attr, Node->Status)) {
+ if (!IsValidMove(Node->FullName, FullCwd, FullDestPath!=NULL?
FullDestPath:DestPath, Node->Info->Attribute, Attr, Node->Status)) {
ShellStatus = SHELL_INVALID_PARAMETER;
continue;
}
@@ -575,6 +588,7 @@
//
// indicate to stop everything
//
+ FreePool(FullCwd);
return (SHELL_ABORTED);
case ShellPromptResponseAll:
*Resp = Response;
@@ -585,12 +599,13 @@
break;
default:
FreePool(Response);
+ FreePool(FullCwd);
return SHELL_ABORTED;
}
Status = ShellDeleteFileByName(FullDestPath!=NULL?
FullDestPath:DestPath);
}
- if (IsBetweenFileSystem(Node->FullName, Cwd, DestPath)) {
+ if (IsBetweenFileSystem(Node->FullName, FullCwd, DestPath)) {
while (FullDestPath == NULL && DestPath != NULL && DestPath[0] !=
CHAR_NULL && DestPath[StrLen(DestPath) - 1] == L'\\') {
DestPath[StrLen(DestPath) - 1] = CHAR_NULL;
}
@@ -631,6 +646,7 @@
SHELL_FREE_NON_NULL(DestPath);
SHELL_FREE_NON_NULL(HiiOutput);
SHELL_FREE_NON_NULL(HiiResultOk);
+ FreePool (FullCwd);
return (ShellStatus);
}
@@ -650,6 +666,8 @@
EFI_STATUS Status;
LIST_ENTRY *Package;
CHAR16 *ProblemParam;
+ CHAR16 *Cwd;
+ UINTN CwdSize;
SHELL_STATUS ShellStatus;
UINTN ParamCount;
UINTN LoopCounter;
@@ -713,7 +731,13 @@
//
// ValidateAndMoveFiles will report errors to the screen itself
//
- ShellStatus = ValidateAndMoveFiles(FileList, &Response,
ShellGetCurrentDir(NULL));
+ CwdSize = StrSize(ShellGetCurrentDir(NULL)) + 1;
+ Cwd = AllocateZeroPool(CwdSize);
+ ASSERT (Cwd != NULL);
+ StrCpyS(Cwd, CwdSize/sizeof(CHAR16), ShellGetCurrentDir(NULL));
+ StrCatS(Cwd, CwdSize/sizeof(CHAR16), L"\\");
+ ShellStatus = ValidateAndMoveFiles(FileList, &Response, Cwd);
+ FreePool(Cwd);
}
}
Modified: branches/UDK2015/ShellPkg/Library/UefiShellLevel2CommandsLib/Rm.c
===================================================================
--- branches/UDK2015/ShellPkg/Library/UefiShellLevel2CommandsLib/Rm.c
2015-12-18 07:29:05 UTC (rev 19394)
+++ branches/UDK2015/ShellPkg/Library/UefiShellLevel2CommandsLib/Rm.c
2015-12-18 07:30:21 UTC (rev 19395)
@@ -231,7 +231,9 @@
Pattern = NULL;
SearchString = NULL;
Size = 0;
- Pattern = StrnCatGrow(&Pattern , NULL, TempLocation , 0);
+ Pattern = StrnCatGrow(&Pattern, &Size, TempLocation , 0);
+ Pattern = StrnCatGrow(&Pattern, &Size, L"\\" , 0);
+ Size = 0;
SearchString = StrnCatGrow(&SearchString, &Size, Node->FullName, 0);
if (!EFI_ERROR(ShellIsDirectory(SearchString))) {
SearchString = StrnCatGrow(&SearchString, &Size, L"\\", 0);
Modified:
branches/UDK2015/ShellPkg/Library/UefiShellLevel2CommandsLib/UefiShellLevel2CommandsLib.c
===================================================================
---
branches/UDK2015/ShellPkg/Library/UefiShellLevel2CommandsLib/UefiShellLevel2CommandsLib.c
2015-12-18 07:29:05 UTC (rev 19394)
+++
branches/UDK2015/ShellPkg/Library/UefiShellLevel2CommandsLib/UefiShellLevel2CommandsLib.c
2015-12-18 07:30:21 UTC (rev 19395)
@@ -22,7 +22,7 @@
* functions are non-interactive only
Copyright (c) 2014 Hewlett-Packard Development Company, L.P.
- 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
@@ -188,6 +188,7 @@
if (StrStr(Path, L":") == NULL) {
CurDir = gEfiShellProtocol->GetCurDir(NULL);
StrnCatGrow(&PathToReturn, &Size, CurDir, 0);
+ StrnCatGrow(&PathToReturn, &Size, L"\\", 0);
if (*Path == L'\\') {
Path++;
}
Modified: branches/UDK2015/ShellPkg/Library/UefiShellLib/UefiShellLib.c
===================================================================
--- branches/UDK2015/ShellPkg/Library/UefiShellLib/UefiShellLib.c
2015-12-18 07:29:05 UTC (rev 19394)
+++ branches/UDK2015/ShellPkg/Library/UefiShellLib/UefiShellLib.c
2015-12-18 07:30:21 UTC (rev 19395)
@@ -1276,6 +1276,8 @@
name. If the DeviceName is not NULL, it returns the current directory name
on specified drive.
+ Note that the current directory string should exclude the tailing backslash
character.
+
@param DeviceName the name of the drive to get directory on
@retval NULL the directory does not exist
@@ -1708,13 +1710,14 @@
Path = ShellGetEnvironmentVariable(L"cwd");
if (Path != NULL) {
- Size = StrSize(Path);
+ Size = StrSize(Path) + sizeof(CHAR16);
Size += StrSize(FileName);
TestPath = AllocateZeroPool(Size);
if (TestPath == NULL) {
return (NULL);
}
StrCpyS(TestPath, Size/sizeof(CHAR16), Path);
+ StrCatS(TestPath, Size/sizeof(CHAR16), L"\\");
StrCatS(TestPath, Size/sizeof(CHAR16), FileName);
Status = ShellOpenFileByName(TestPath, &Handle, EFI_FILE_MODE_READ, 0);
if (!EFI_ERROR(Status)){
------------------------------------------------------------------------------
_______________________________________________
edk2-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-commits