summaryrefslogtreecommitdiffstats
path: root/crypto
diff options
context:
space:
mode:
authorPauli <ppzgs1@gmail.com>2021-03-17 13:25:11 +1000
committerPauli <ppzgs1@gmail.com>2021-03-20 10:18:32 +1000
commit72ded6f2a93085f536b4a820ab42b2da26fecf1c (patch)
tree0280e1246ac9a8ce568b6a45d83206a7e8982d1c /crypto
parentf1619160c89d5394f0cb9626d1198ef5180448db (diff)
x509: coverity 1472673 & 1472693 - dereference after null checks
Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/14589)
Diffstat (limited to 'crypto')
-rw-r--r--crypto/x509/x509_cmp.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/crypto/x509/x509_cmp.c b/crypto/x509/x509_cmp.c
index a149bf49dc..3ced70b21f 100644
--- a/crypto/x509/x509_cmp.c
+++ b/crypto/x509/x509_cmp.c
@@ -251,18 +251,21 @@ int X509_NAME_cmp(const X509_NAME *a, const X509_NAME *b)
return -1;
/* Ensure canonical encoding is present and up to date */
- if (!a->canon_enc || a->modified) {
+ if (a->canon_enc == NULL || a->modified) {
ret = i2d_X509_NAME((X509_NAME *)a, NULL);
if (ret < 0)
return -2;
}
- if (!b->canon_enc || b->modified) {
+ if (b->canon_enc == NULL || b->modified) {
ret = i2d_X509_NAME((X509_NAME *)b, NULL);
if (ret < 0)
return -2;
}
+ if (a->canon_enc == NULL || b->canon_enc == NULL)
+ return -2;
+
ret = a->canon_enclen - b->canon_enclen;
if (ret == 0 && a->canon_enclen != 0)
ret = memcmp(a->canon_enc, b->canon_enc, a->canon_enclen);