]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ShellPkg/Shell - Fix ASSERT() when FvSimpleFileSystemDxe is used
authorMichael Kinney <michael.d.kinney@intel.com>
Sat, 12 Dec 2015 19:28:21 +0000 (19:28 +0000)
committermdkinney <mdkinney@Edk2>
Sat, 12 Dec 2015 19:28:21 +0000 (19:28 +0000)
When the FvSimpleFileSystemDxe module is included in a platform,
Simple File System Protocols are produced for firmware volumes(FV)
that do not have the same style device paths as file systems with
file names.  The ShellPkg has an assumption that the device path
contains device path nodes of type MEDIA_FILEPATH_DP and generates
an ASSERT() if any other device path nodes are encountered.  This
change removes the ASSERT() condition and instead returns NULL that
means EfiShellGetFilePathFromDevicePath() can not convert the
device path nodes that represent the file path to a Unicode string.

Cc: Jaben Carsey <jaben.carsey@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Michael Kinney <michael.d.kinney@intel.com>
Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@19228 6f19259b-4bc3-4df7-8a09-765794883524

ShellPkg/Application/Shell/ShellProtocol.c

index 9c370ccef5afc938e86d1801167bdc6ada476986..def3bd35c208e6a7a669a744e55db1cd338231ee 100644 (file)
@@ -449,38 +449,37 @@ EfiShellGetFilePathFromDevicePath(
           ; FilePath = (FILEPATH_DEVICE_PATH*)NextDevicePathNode (&FilePath->Header)\r
          ){\r
         //\r
           ; FilePath = (FILEPATH_DEVICE_PATH*)NextDevicePathNode (&FilePath->Header)\r
          ){\r
         //\r
-        // all the rest should be file path nodes\r
+        // If any node is not a file path node, then the conversion can not be completed\r
         //\r
         if ((DevicePathType(&FilePath->Header) != MEDIA_DEVICE_PATH) ||\r
             (DevicePathSubType(&FilePath->Header) != MEDIA_FILEPATH_DP)) {\r
           FreePool(PathForReturn);\r
         //\r
         if ((DevicePathType(&FilePath->Header) != MEDIA_DEVICE_PATH) ||\r
             (DevicePathSubType(&FilePath->Header) != MEDIA_FILEPATH_DP)) {\r
           FreePool(PathForReturn);\r
-          PathForReturn = NULL;\r
-          ASSERT(FALSE);\r
-        } else {\r
-          //\r
-          // append the path part onto the filepath.\r
-          //\r
-          ASSERT((PathForReturn == NULL && PathSize == 0) || (PathForReturn != NULL));\r
-\r
-          AlignedNode = AllocateCopyPool (DevicePathNodeLength(FilePath), FilePath);\r
-          ASSERT (AlignedNode != NULL);\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 ((PathSize != 0)                        &&\r
-              (PathForReturn != NULL)                &&\r
-              (PathForReturn[PathSize - 1] != L'\\') &&\r
-              (AlignedNode->PathName[0]    != L'\\')) {\r
-            PathForReturn = StrnCatGrow (&PathForReturn, &PathSize, L"\\", 1);\r
-          }\r
+          return NULL;\r
+        }\r
 \r
 \r
-          PathForReturn = StrnCatGrow(&PathForReturn, &PathSize, AlignedNode->PathName, 0);\r
-          FreePool(AlignedNode);\r
+        //\r
+        // append the path part onto the filepath.\r
+        //\r
+        ASSERT((PathForReturn == NULL && PathSize == 0) || (PathForReturn != NULL));\r
+\r
+        AlignedNode = AllocateCopyPool (DevicePathNodeLength(FilePath), FilePath);\r
+        ASSERT (AlignedNode != NULL);\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 ((PathSize != 0)                        &&\r
+            (PathForReturn != NULL)                &&\r
+            (PathForReturn[PathSize - 1] != L'\\') &&\r
+            (AlignedNode->PathName[0]    != L'\\')) {\r
+          PathForReturn = StrnCatGrow (&PathForReturn, &PathSize, L"\\", 1);\r
         }\r
         }\r
+\r
+        PathForReturn = StrnCatGrow(&PathForReturn, &PathSize, AlignedNode->PathName, 0);\r
+        FreePool(AlignedNode);\r
       } // for loop of remaining nodes\r
     }\r
     if (PathForReturn != NULL) {\r
       } // for loop of remaining nodes\r
     }\r
     if (PathForReturn != NULL) {\r