]> git.proxmox.com Git - mirror_edk2.git/blobdiff - CryptoPkg/Library/BaseCryptLib/Pem/CryptPem.c
Enhance error handling code after calling BIO_new in BaseCryptLib.
[mirror_edk2.git] / CryptoPkg / Library / BaseCryptLib / Pem / CryptPem.c
index 078a960d5848e7084ec7516329da7e1da0508c1b..51e648b736a51c9f41d3a24d67a235b937c8f95b 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   PEM (Privacy Enhanced Mail) Format Handler Wrapper Implementation over OpenSSL.\r
 \r
-Copyright (c) 2010 - 2012, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2010 - 2013, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
@@ -109,11 +109,14 @@ RsaGetPrivateKeyFromPem (
   // Read encrypted PEM Data.\r
   //\r
   PemBio = BIO_new (BIO_s_mem ());\r
-  BIO_write (PemBio, PemData, (int) PemSize);\r
   if (PemBio == NULL) {\r
     goto _Exit;\r
   }\r
 \r
+  if (BIO_write (PemBio, PemData, (int) PemSize) <= 0) {\r
+    goto _Exit;\r
+  }\r
+\r
   //\r
   // Retrieve RSA Private Key from encrypted PEM data.\r
   //\r