X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=MdePkg%2FLibrary%2FBasePeCoffLib%2FBasePeCoff.c;h=71089bbb0de6afda69c87e9657edba70841a88f1;hp=e44f04c799308e6c298d682a78775e02034edd38;hb=dc204d5a0fd64d1ccbc90ebea827e7ad73b71f4d;hpb=90eaa3c1e022e2b676da65cb41aa66136a18b4ea diff --git a/MdePkg/Library/BasePeCoffLib/BasePeCoff.c b/MdePkg/Library/BasePeCoffLib/BasePeCoff.c index e44f04c799..71089bbb0d 100644 --- a/MdePkg/Library/BasePeCoffLib/BasePeCoff.c +++ b/MdePkg/Library/BasePeCoffLib/BasePeCoff.c @@ -2,6 +2,19 @@ Base PE/COFF loader supports loading any PE32/PE32+ or TE image, but only supports relocating IA32, x64, IPF, and EBC images. + Caution: This file requires additional review when modified. + This library will have external input - PE/COFF image. + This external input must be validated carefully to avoid security issue like + buffer overflow, integer overflow. + + The basic guideline is that caller need provide ImageContext->ImageRead () with the + necessary data range check, to make sure when this library reads PE/COFF image, the + PE image buffer is always in valid range. + This library will also do some additional check for PE header fields. + + PeCoffLoaderGetPeHeader() routine will do basic check for PE/COFF header. + PeCoffLoaderGetImageInfo() routine will do basic check for whole PE/COFF image. + Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.
Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.
This program and the accompanying materials @@ -48,7 +61,10 @@ PeCoffLoaderGetPeHeaderMagicValue ( /** Retrieves the PE or TE Header from a PE/COFF or TE image. - Also done many checks in PE image to make sure PE image DosHeader, PeOptionHeader, + + Caution: This function may receive untrusted input. + PE/COFF image is external input, so this routine will + also done many checks in PE image to make sure PE image DosHeader, PeOptionHeader, SizeOfHeader, Section Data Region and Security Data Region be in PE image range. @param ImageContext The context of the image being loaded. @@ -376,7 +392,9 @@ PeCoffLoaderGetPeHeader ( The ImageRead and Handle fields of ImageContext structure must be valid prior to invoking this service. - Also done many checks in PE image to make sure PE image DosHeader, PeOptionHeader, + Caution: This function may receive untrusted input. + PE/COFF image is external input, so this routine will + also done many checks in PE image to make sure PE image DosHeader, PeOptionHeader, SizeOfHeader, Section Data Region and Security Data Region be in PE image range. @param ImageContext The pointer to the image context structure that describes the PE/COFF