From 6beb225a9a20e791157937d095159c7d61b6ec20 Mon Sep 17 00:00:00 2001 From: lgao4 Date: Wed, 16 Feb 2011 01:18:28 +0000 Subject: Per PI1.2B spec, for the case that TE Image Relocation Data Directory Entry Virtual Address is non-zero, but the Relocation Data Directory Size is zero, BasePeCoffLib should only handle such case as PIC TE image. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11315 6f19259b-4bc3-4df7-8a09-765794883524 --- MdePkg/Library/BasePeCoffLib/BasePeCoff.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'MdePkg/Library/BasePeCoffLib') diff --git a/MdePkg/Library/BasePeCoffLib/BasePeCoff.c b/MdePkg/Library/BasePeCoffLib/BasePeCoff.c index 7337bc359a..064917cd9b 100644 --- a/MdePkg/Library/BasePeCoffLib/BasePeCoff.c +++ b/MdePkg/Library/BasePeCoffLib/BasePeCoff.c @@ -2,7 +2,7 @@ Base PE/COFF loader supports loading any PE32/PE32+ or TE image, but only supports relocating IA32, x64, IPF, and EBC images. - Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.
+ Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.
Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License @@ -279,6 +279,14 @@ PeCoffLoaderGetImageInfo ( } else { ImageContext->RelocationsStripped = FALSE; } + + // + // TE Image Relocation Data Directory Entry size is non-zero, but the Relocation Data Directory Virtual Address is zero. + // This case is not a valid TE image. + // + if ((ImageContext->IsTeImage) && (Hdr.Te->DataDirectory[0].Size != 0) && (Hdr.Te->DataDirectory[0].VirtualAddress == 0)) { + return RETURN_INVALID_PARAMETER; + } if (!(ImageContext->IsTeImage)) { if (Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) { -- cgit v1.2.3