Revision: 17731 http://sourceforge.net/p/edk2/code/17731 Author: qlong Date: 2015-06-30 03:27:23 +0000 (Tue, 30 Jun 2015) Log Message: ----------- CryptoPkg: Fix the dereferenced pointer issue
This patch is to fix one dereferenced pointer issue in new Pkcs7GetAttachedContent API, and add the memory allocation failure check. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Qin Long <qin.l...@intel.com> Reviewed-by: Ye Ting <ting...@intel.com> Modified Paths: -------------- trunk/edk2/CryptoPkg/Library/BaseCryptLib/Pk/CryptPkcs7Verify.c Modified: trunk/edk2/CryptoPkg/Library/BaseCryptLib/Pk/CryptPkcs7Verify.c =================================================================== --- trunk/edk2/CryptoPkg/Library/BaseCryptLib/Pk/CryptPkcs7Verify.c 2015-06-30 03:18:31 UTC (rev 17730) +++ trunk/edk2/CryptoPkg/Library/BaseCryptLib/Pk/CryptPkcs7Verify.c 2015-06-30 03:27:23 UTC (rev 17731) @@ -719,11 +719,6 @@ CONST UINT8 *Temp; ASN1_OCTET_STRING *OctStr; - *Content = NULL; - Pkcs7 = NULL; - SignedData = NULL; - OctStr = NULL; - // // Check input parameter. // @@ -731,6 +726,11 @@ return FALSE; } + *Content = NULL; + Pkcs7 = NULL; + SignedData = NULL; + OctStr = NULL; + Status = WrapPkcs7Data (P7Data, P7Length, &Wrapped, &SignedData, &SignedDataSize); if (!Status || (SignedDataSize > INT_MAX)) { goto _Exit; @@ -771,6 +771,10 @@ if ((OctStr->length > 0) && (OctStr->data != NULL)) { *ContentSize = OctStr->length; *Content = malloc (*ContentSize); + if (*Content == NULL) { + *ContentSize = 0; + goto _Exit; + } CopyMem (*Content, OctStr->data, *ContentSize); } } ------------------------------------------------------------------------------ Don't Limit Your Business. Reach for the Cloud. GigeNET's Cloud Solutions provide you with the tools and support that you need to offload your IT needs and focus on growing your business. Configured For All Businesses. Start Your Cloud Today. https://www.gigenetcloud.com/ _______________________________________________ edk2-commits mailing list edk2-commits@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/edk2-commits