From 1463ce18ca7c4f971c08cc6341dbb0adb25c831a Mon Sep 17 00:00:00 2001 From: Qin Long Date: Tue, 16 Jun 2015 00:54:16 +0000 Subject: CryptoPkg: Wrapper files updates to support openssl-1.0.2c This patch updates some support header and wrapper files to support openssl-1.0.2c build, and correct some openssl API usages and boundary check. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Qin Long Reviewed-by: Ard Biesheuvel git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@17635 6f19259b-4bc3-4df7-8a09-765794883524 --- CryptoPkg/Library/BaseCryptLib/Pk/CryptX509.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'CryptoPkg/Library/BaseCryptLib/Pk/CryptX509.c') diff --git a/CryptoPkg/Library/BaseCryptLib/Pk/CryptX509.c b/CryptoPkg/Library/BaseCryptLib/Pk/CryptX509.c index 29efc42b02..02851d5701 100644 --- a/CryptoPkg/Library/BaseCryptLib/Pk/CryptX509.c +++ b/CryptoPkg/Library/BaseCryptLib/Pk/CryptX509.c @@ -1,7 +1,7 @@ /** @file X.509 Certificate Handler Wrapper Implementation over OpenSSL. -Copyright (c) 2010 - 2014, Intel Corporation. All rights reserved.
+Copyright (c) 2010 - 2015, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -38,7 +38,8 @@ X509ConstructCertificate ( OUT UINT8 **SingleX509Cert ) { - X509 *X509Cert; + X509 *X509Cert; + CONST UINT8 *Temp; // // Check input parameters. @@ -50,7 +51,8 @@ X509ConstructCertificate ( // // Read DER-encoded X509 Certificate and Construct X509 object. // - X509Cert = d2i_X509 (NULL, &Cert, (long) CertSize); + Temp = Cert; + X509Cert = d2i_X509 (NULL, &Temp, (long) CertSize); if (X509Cert == NULL) { return FALSE; } @@ -123,6 +125,9 @@ X509ConstructCertificateStack ( } CertSize = VA_ARG (Args, UINTN); + if (CertSize == 0) { + break; + } // // Construct X509 Object from the given DER-encoded certificate data. @@ -133,7 +138,9 @@ X509ConstructCertificateStack ( (UINT8 **) &X509Cert ); if (!Status) { - X509_free (X509Cert); + if (X509Cert != NULL) { + X509_free (X509Cert); + } break; } @@ -518,7 +525,8 @@ X509GetTBSCert ( // // Check input parameters. // - if ((Cert == NULL) || (TBSCert == NULL) || (TBSCertSize == NULL)) { + if ((Cert == NULL) || (TBSCert == NULL) || + (TBSCertSize == NULL) || (CertSize > INT_MAX)) { return FALSE; } -- cgit v1.2.3