OcAppleImageVerification: Fix function prototype

A callee should never free caller data for design reasons. Return the caller parameter in the future if it is ever required for any other API.
This commit is contained in:
Download-Fritz 2019-11-13 21:27:59 +01:00
parent 268ae1b544
commit 2cac6fd25f
2 changed files with 17 additions and 23 deletions

View File

@ -85,8 +85,7 @@ GetApplePeImageSha256 (
EFI_STATUS
VerifyApplePeImageSignature (
IN OUT VOID *PeImage,
IN OUT UINTN *ImageSize,
IN OUT APPLE_PE_COFF_LOADER_IMAGE_CONTEXT *Context OPTIONAL
IN OUT UINTN *ImageSize
);
#endif //APPLE_DXE_IMAGE_VERIFICATION_H

View File

@ -581,31 +581,26 @@ GetApplePeImageSha256 (
EFI_STATUS
VerifyApplePeImageSignature (
IN OUT VOID *PeImage,
IN OUT UINTN *ImageSize,
IN OUT APPLE_PE_COFF_LOADER_IMAGE_CONTEXT *Context OPTIONAL
IN OUT UINTN *ImageSize
)
{
UINTN Index = 0;
APPLE_SIGNATURE_CONTEXT *SignatureContext = NULL;
OC_RSA_PUBLIC_KEY *Pk = NULL;
UINTN Index = 0;
APPLE_SIGNATURE_CONTEXT *SignatureContext = NULL;
OC_RSA_PUBLIC_KEY *Pk = NULL;
APPLE_PE_COFF_LOADER_IMAGE_CONTEXT *Context = NULL;
//
// Build context if not present
//
Context = AllocateZeroPool (sizeof (APPLE_PE_COFF_LOADER_IMAGE_CONTEXT));
if (Context == NULL) {
Context = AllocateZeroPool (sizeof (APPLE_PE_COFF_LOADER_IMAGE_CONTEXT));
if (Context == NULL) {
DEBUG ((DEBUG_WARN, "Pe context allocation failure\n"));
return EFI_OUT_OF_RESOURCES;
}
//
// Build PE context
//
if (EFI_ERROR (BuildPeContext (PeImage, *ImageSize, Context))) {
DEBUG ((DEBUG_WARN, "Malformed ApplePeImage\n"));
FreePool (Context);
return EFI_INVALID_PARAMETER;
}
DEBUG ((DEBUG_WARN, "Pe context allocation failure\n"));
return EFI_OUT_OF_RESOURCES;
}
//
// Build PE context
//
if (EFI_ERROR (BuildPeContext (PeImage, *ImageSize, Context))) {
DEBUG ((DEBUG_WARN, "Malformed ApplePeImage\n"));
FreePool (Context);
return EFI_INVALID_PARAMETER;
}
//