Added back safety check for PE/COFF image walking. I think the safety check is broken...
authorajfish <ajfish@6f19259b-4bc3-4df7-8a09-765794883524>
Wed, 26 Jul 2006 23:34:08 +0000 (23:34 +0000)
committerajfish <ajfish@6f19259b-4bc3-4df7-8a09-765794883524>
Wed, 26 Jul 2006 23:34:08 +0000 (23:34 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@1108 6f19259b-4bc3-4df7-8a09-765794883524

MdePkg/Library/BasePeCoffLib/BasePeCoff.c

index 1e8f573..6d36b6d 100644 (file)
@@ -488,6 +488,15 @@ PeCoffLoaderImageAddress (
   IN     UINTN                                 Address\r
   )\r
 {\r
+  //\r
+  // @bug Check to make sure ImageSize is correct for the relocated image. \r
+  //      it may only work for the file we start with and not the relocated image\r
+  //\r
+  if (Address >= ImageContext->ImageSize) {\r
+    ImageContext->ImageError = IMAGE_ERROR_INVALID_IMAGE_ADDRESS;\r
+    return NULL;\r
+  }\r
+\r
   return (CHAR8 *)((UINTN) ImageContext->ImageAddress + Address);\r
 }\r
 \r