]> git.proxmox.com Git - mirror_edk2.git/blobdiff - CryptoPkg/Library/BaseCryptLib/Pk/CryptDh.c
CryptoPkg BaseCryptLib: Avoid passing NULL ptr to function BN_bn2bin()
[mirror_edk2.git] / CryptoPkg / Library / BaseCryptLib / Pk / CryptDh.c
index 9cbf182c70f5b292a39ab2b67107208fa0173e26..5e0447b488a3396adaab31076af078fb63f86bae 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Diffie-Hellman Wrapper Implementation over OpenSSL.\r
 \r
-Copyright (c) 2010 - 2015, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2010 - 2016, 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
@@ -246,7 +246,11 @@ DhGenerateKey (
   RetVal = (BOOLEAN) DH_generate_key (DhContext);\r
   if (RetVal) {\r
     Size = BN_num_bytes (Dh->pub_key);\r
-    if ((Size > 0) && (*PublicKeySize < (UINTN) Size)) {\r
+    if (Size <= 0) {\r
+      *PublicKeySize = 0;\r
+      return FALSE;\r
+    }\r
+    if (*PublicKeySize < (UINTN) Size) {\r
       *PublicKeySize = Size;\r
       return FALSE;\r
     }\r