diff options
author | Hao Wu <hao.a.wu@intel.com> | 2016-07-01 15:12:40 +0800 |
---|---|---|
committer | Hao Wu <hao.a.wu@intel.com> | 2016-07-05 08:59:37 +0800 |
commit | 0856396e67562cf7f288f176a09bb1c6e0ea6464 (patch) | |
tree | 1d2188055514c935a8de062721f3fdebb24af200 | |
parent | 2292c87ec3ee8829e335ee315f849b30be9da3c4 (diff) | |
download | edk2-0856396e67562cf7f288f176a09bb1c6e0ea6464.tar.gz |
CryptoPkg BaseCryptLib: Avoid passing NULL ptr to function BN_bn2bin()
This commit modifies codes to avoid passing NULL pointer to function
BN_bn2bin().
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
-rw-r--r-- | CryptoPkg/Library/BaseCryptLib/Pk/CryptDh.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/CryptoPkg/Library/BaseCryptLib/Pk/CryptDh.c b/CryptoPkg/Library/BaseCryptLib/Pk/CryptDh.c index 942b3d103e..45952e7f34 100644 --- a/CryptoPkg/Library/BaseCryptLib/Pk/CryptDh.c +++ b/CryptoPkg/Library/BaseCryptLib/Pk/CryptDh.c @@ -245,7 +245,11 @@ DhGenerateKey ( RetVal = (BOOLEAN) DH_generate_key (DhContext);
if (RetVal) {
Size = BN_num_bytes (Dh->pub_key);
- if ((Size > 0) && (*PublicKeySize < (UINTN) Size)) {
+ if (Size <= 0) {
+ *PublicKeySize = 0;
+ return FALSE;
+ }
+ if (*PublicKeySize < (UINTN) Size) {
*PublicKeySize = Size;
return FALSE;
}
|