esys_crypto: fix defects reported by Coverity Scan
Fix two potential null ptr dereference issues reported by coverity.
CID 1468838: Null pointer dereferences (REVERSE_INULL)
Null-checking "partyUInfo" suggests that it may be null,
but it has already been dereferenced on all paths leading to the check.
CID 1468837: Null pointer dereferences (REVERSE_INULL)
Null-checking "partyVInfo" suggests that it may be null,
but it has already been dereferenced on all paths leading to the check.
Fixes: #1011
Signed-off-by: Tadeusz Struk <tadeusz.struk@intel.com>
diff --git a/src/tss2-esys/esys_crypto.c b/src/tss2-esys/esys_crypto.c
index 0f7fb22..0c9cfc9 100644
--- a/src/tss2-esys/esys_crypto.c
+++ b/src/tss2-esys/esys_crypto.c
@@ -948,8 +948,13 @@
LOG_DEBUG("IESYS KDFe hashAlg: %i label: %s bitLength: %i",
hashAlg, label, bit_size);
- LOGBLOB_DEBUG(&partyUInfo->buffer[0], partyUInfo->size, "partyUInfo");
- LOGBLOB_DEBUG(&partyVInfo->buffer[0], partyVInfo->size, "partyVInfo");
+
+ if (partyUInfo != NULL)
+ LOGBLOB_DEBUG(&partyUInfo->buffer[0], partyUInfo->size, "partyUInfo");
+
+ if (partyVInfo != NULL)
+ LOGBLOB_DEBUG(&partyVInfo->buffer[0], partyVInfo->size, "partyVInfo");
+
r = iesys_crypto_hash_get_digest_size(hashAlg, &hash_len);
return_if_error(r, "Hash algorithm not supported.");