]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ShellPkg/ShellProtocol.c: Don't put consective "\"s in file paths
authorBrendan Jackman <Brendan.Jackman@arm.com>
Fri, 24 Jan 2014 22:32:38 +0000 (22:32 +0000)
committeroliviermartin <oliviermartin@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 24 Jan 2014 22:32:38 +0000 (22:32 +0000)
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

ShellPkg/Application/Shell/ShellProtocol.c

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