From 6ddc2ff3efa00b0e2233ae28f64cf58d63dafd2a Mon Sep 17 00:00:00 2001 From: Brendan Jackman Date: Fri, 24 Jan 2014 22:32:38 +0000 Subject: [PATCH] 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 Reviewed-by: Olivier Martin Reviewed-by: Jaben Carsey git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15184 6f19259b-4bc3-4df7-8a09-765794883524 --- ShellPkg/Application/Shell/ShellProtocol.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/ShellPkg/Application/Shell/ShellProtocol.c b/ShellPkg/Application/Shell/ShellProtocol.c index 0d3839783e..fe63e6a8d6 100644 --- a/ShellPkg/Application/Shell/ShellProtocol.c +++ b/ShellPkg/Application/Shell/ShellProtocol.c @@ -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); } -- 2.39.2