]> git.proxmox.com Git - mirror_edk2.git/commitdiff
OvmfPkg/QemuBootOrderLib: allow slash in rom filenames
authorGerd Hoffmann <kraxel@redhat.com>
Wed, 21 Sep 2022 05:30:44 +0000 (07:30 +0200)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Wed, 28 Sep 2022 10:46:29 +0000 (10:46 +0000)
See comment for details.  Needed to avoid the parser abort,
so we can continue parsing the bootorder fw_cfg file.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.c

index 398de7fab4ba8b771c2947a12b43407cb93c9c2d..374c6d8f5e9152352a1bdbc8d0f4aaceead943ab 100644 (file)
@@ -432,6 +432,8 @@ ParseOfwNode (
   OUT     BOOLEAN      *IsFinal\r
   )\r
 {\r
+  BOOLEAN  AcceptSlash = FALSE;\r
+\r
   //\r
   // A leading slash is expected. End of string is tolerated.\r
   //\r
@@ -464,6 +466,21 @@ ParseOfwNode (
     return RETURN_INVALID_PARAMETER;\r
   }\r
 \r
+  if (SubstringEq (OfwNode->DriverName, "rom")) {\r
+    //\r
+    // bug compatibility hack\r
+    //\r
+    // qemu passes fw_cfg filenames as rom unit address.\r
+    // The filenames have slashes:\r
+    //      /rom@genroms/linuxboot_dma.bin\r
+    //\r
+    // Alow slashes in the unit address to avoid the parser trip up,\r
+    // so we can successfully parse the following lines (the rom\r
+    // entries themself are ignored).\r
+    //\r
+    AcceptSlash = TRUE;\r
+  }\r
+\r
   //\r
   // unit-address\r
   //\r
@@ -475,7 +492,7 @@ ParseOfwNode (
 \r
   OfwNode->UnitAddress.Ptr = *Ptr;\r
   OfwNode->UnitAddress.Len = 0;\r
-  while (IsPrintNotDelim (**Ptr)) {\r
+  while (IsPrintNotDelim (**Ptr) || (AcceptSlash && **Ptr == '/')) {\r
     ++*Ptr;\r
     ++OfwNode->UnitAddress.Len;\r
   }\r