This commit modifies the code logic to avoid passing NULL pointer to
function BN_bn2bin().
Cc: Long Qin <qin.long@intel.com>
Cc: Ye Ting <ting.ye@intel.com>
Cc: Fu Siyuan <siyuan.fu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
Reviewed-by: Qin Long <qin.long@intel.com>
/** @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
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