]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Fix the issue in PeiCore to support PDB file path without '\' or '.' character.
authorlgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524>
Wed, 29 Feb 2012 04:56:53 +0000 (04:56 +0000)
committerlgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524>
Wed, 29 Feb 2012 04:56:53 +0000 (04:56 +0000)
Signed-off-by: lgao4
Reviewed-by: rsun3
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@13069 6f19259b-4bc3-4df7-8a09-765794883524

MdeModulePkg/Core/Pei/Image/Image.c

index 843e0201425a0f02cfbb152ebeca70e28d0f4d95..41069e7a31fd2f562012614de815821741fe444e 100644 (file)
@@ -549,9 +549,9 @@ PeiLoadImageLoadImage (
 \r
   DEBUG_CODE_BEGIN ();\r
     CHAR8                              *AsciiString;\r
-    CHAR8                              AsciiBuffer[512];\r
+    CHAR8                              EfiFileName[512];\r
     INT32                              Index;\r
-    INT32                              Index1;\r
+    INT32                              StartIndex;\r
 \r
     //\r
     // Print debug message: Loading PEIM at 0x12345678 EntryPoint=0x12345688 Driver.efi\r
@@ -571,19 +571,37 @@ PeiLoadImageLoadImage (
     AsciiString = PeCoffLoaderGetPdbPointer (Pe32Data);\r
 \r
     if (AsciiString != NULL) {\r
-      for (Index = (INT32) AsciiStrLen (AsciiString) - 1; Index >= 0; Index --) {\r
+      StartIndex = 0;\r
+      for (Index = 0; AsciiString[Index] != 0; Index++) {\r
         if (AsciiString[Index] == '\\' || AsciiString[Index] == '/') {\r
-          break;\r
+          StartIndex = Index + 1;\r
         }\r
       }\r
 \r
-      if (Index != 0) {\r
-        for (Index1 = 0; AsciiString[Index + 1 + Index1] != '.'; Index1 ++) {\r
-          AsciiBuffer [Index1] = AsciiString[Index + 1 + Index1];\r
+      //\r
+      // Copy the PDB file name to our temporary string, and replace .pdb with .efi\r
+      // The PDB file name is limited in the range of 0~511.\r
+      // If the length is bigger than 511, trim the redudant characters to avoid overflow in array boundary.\r
+      //\r
+      for (Index = 0; Index < sizeof (EfiFileName) - 4; Index++) {\r
+        EfiFileName[Index] = AsciiString[Index + StartIndex];\r
+        if (EfiFileName[Index] == 0) {\r
+          EfiFileName[Index] = '.';\r
+        }\r
+        if (EfiFileName[Index] == '.') {\r
+          EfiFileName[Index + 1] = 'e';\r
+          EfiFileName[Index + 2] = 'f';\r
+          EfiFileName[Index + 3] = 'i';\r
+          EfiFileName[Index + 4] = 0;\r
+          break;\r
         }\r
-        AsciiBuffer [Index1] = '\0';\r
-        DEBUG ((EFI_D_INFO | EFI_D_LOAD, "%a.efi", AsciiBuffer));\r
       }\r
+\r
+      if (Index == sizeof (EfiFileName) - 4) {\r
+        EfiFileName[Index] = 0;\r
+      }\r
+\r
+      DEBUG ((EFI_D_INFO | EFI_D_LOAD, "%a", EfiFileName));\r
     }\r
 \r
   DEBUG_CODE_END ();\r