From 236877a6a7a89512ee67d8bc168dd4c16b85e8db Mon Sep 17 00:00:00 2001 From: ajfish Date: Wed, 26 Jul 2006 23:34:08 +0000 Subject: [PATCH] Added back safety check for PE/COFF image walking. I think the safety check is broken in some places (Linux) but we need to investigate more. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@1108 6f19259b-4bc3-4df7-8a09-765794883524 --- MdePkg/Library/BasePeCoffLib/BasePeCoff.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/MdePkg/Library/BasePeCoffLib/BasePeCoff.c b/MdePkg/Library/BasePeCoffLib/BasePeCoff.c index 1e8f573009..6d36b6dff0 100644 --- a/MdePkg/Library/BasePeCoffLib/BasePeCoff.c +++ b/MdePkg/Library/BasePeCoffLib/BasePeCoff.c @@ -488,6 +488,15 @@ PeCoffLoaderImageAddress ( IN UINTN Address ) { + // + // @bug Check to make sure ImageSize is correct for the relocated image. + // it may only work for the file we start with and not the relocated image + // + if (Address >= ImageContext->ImageSize) { + ImageContext->ImageError = IMAGE_ERROR_INVALID_IMAGE_ADDRESS; + return NULL; + } + return (CHAR8 *)((UINTN) ImageContext->ImageAddress + Address); }