From 4d6afad3b90f169dc15f0d21b2067b07ef7b714e Mon Sep 17 00:00:00 2001 From: tye1 Date: Fri, 25 Nov 2011 07:07:01 +0000 Subject: Fix CrytoPkg issue in GCC X64 tip. Signed-off-by: tye Reviewed-by: gdong1 Reviewed-by: ftian git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@12784 6f19259b-4bc3-4df7-8a09-765794883524 --- CryptoPkg/Library/BaseCryptLib/Pk/CryptPkcs7.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'CryptoPkg/Library/BaseCryptLib/Pk') diff --git a/CryptoPkg/Library/BaseCryptLib/Pk/CryptPkcs7.c b/CryptoPkg/Library/BaseCryptLib/Pk/CryptPkcs7.c index 47bab1004b..83f0dfcd5a 100644 --- a/CryptoPkg/Library/BaseCryptLib/Pk/CryptPkcs7.c +++ b/CryptoPkg/Library/BaseCryptLib/Pk/CryptPkcs7.c @@ -190,6 +190,7 @@ Pkcs7Sign ( // Key = EVP_PKEY_new (); if (Key == NULL) { + Status = FALSE; goto _Exit; } Key->save_type = EVP_PKEY_RSA; @@ -213,6 +214,7 @@ Pkcs7Sign ( PKCS7_BINARY | PKCS7_NOATTR | PKCS7_DETACHED ); if (Pkcs7 == NULL) { + Status = FALSE; goto _Exit; } @@ -221,9 +223,16 @@ Pkcs7Sign ( // P7DataSize = i2d_PKCS7 (Pkcs7, NULL); if (P7DataSize <= 19) { + Status = FALSE; goto _Exit; } + P7Data = OPENSSL_malloc (P7DataSize); + if (P7Data == NULL) { + Status = FALSE; + goto _Exit; + } + Tmp = P7Data; P7DataSize = i2d_PKCS7 (Pkcs7, (unsigned char **) &Tmp); @@ -233,6 +242,12 @@ Pkcs7Sign ( // *SignedDataSize = P7DataSize - 19; *SignedData = OPENSSL_malloc (*SignedDataSize); + if (*SignedData == NULL) { + Status = FALSE; + OPENSSL_free (P7Data); + goto _Exit; + } + CopyMem (*SignedData, P7Data + 19, *SignedDataSize); OPENSSL_free (P7Data); -- cgit v1.2.3