ShellPkg/ShellProtocol.c: Don't put consective "\"s in file paths

The UEFI and UEFI Shell specs do not allow consecutive path separators.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Brendan Jackman <Brendan.Jackman@arm.com>
Reviewed-by: Olivier Martin <olivier.martin@arm.com>
Reviewed-by: Jaben Carsey <Jaben.carsey@intel.com>



git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15184 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
Brendan Jackman 2014-01-24 22:32:38 +00:00 committed by oliviermartin
parent 3877d0f581
commit 6ddc2ff3ef
1 changed files with 12 additions and 1 deletions

View File

@ -458,9 +458,20 @@ EfiShellGetFilePathFromDevicePath(
// append the path part onto the filepath.
//
ASSERT((PathForReturn == NULL && PathSize == 0) || (PathForReturn != NULL));
PathForReturn = StrnCatGrow(&PathForReturn, &PathSize, L"\\", 1);
AlignedNode = AllocateCopyPool (DevicePathNodeLength(FilePath), FilePath);
// File Path Device Path Nodes 'can optionally add a "\" separator to
// the beginning and/or the end of the Path Name string.'
// (UEFI Spec 2.4 section 9.3.6.4).
// If necessary, add a "\", but otherwise don't
// (This is specified in the above section, and also implied by the
// UEFI Shell spec section 3.7)
if ((PathForReturn[PathSize - 1] != L'\\') &&
(AlignedNode->PathName[0] != L'\\')) {
PathForReturn = StrnCatGrow (&PathForReturn, &PathSize, L"\\", 1);
}
PathForReturn = StrnCatGrow(&PathForReturn, &PathSize, AlignedNode->PathName, 0);
FreePool(AlignedNode);
}