]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
X509_NAME_cmp: if canon_enclen is 0 for both names return 0
authorTomas Mraz <tomas@openssl.org>
Mon, 12 Apr 2021 07:58:27 +0000 (09:58 +0200)
committerTomas Mraz <tomas@openssl.org>
Wed, 14 Apr 2021 07:45:40 +0000 (09:45 +0200)
We do not care whether canon_enc is NULL in this case.

Fixes #14813

Reviewed-by: David von Oheimb <david.von.oheimb@siemens.com>
(Merged from https://github.com/openssl/openssl/pull/14832)

crypto/x509/x509_cmp.c

index 51dc24b6fb3d49611e94ac955f4cae3c0ea13f80..0cc5ed7f5f7f87a1f30cf48bb3e3a6aec1b197ab 100644 (file)
@@ -269,11 +269,14 @@ int X509_NAME_cmp(const X509_NAME *a, const X509_NAME *b)
             return -2;
     }
 
+    ret = a->canon_enclen - b->canon_enclen;
+    if (ret == 0 && a->canon_enclen == 0)
+        return 0;
+
     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)
+    if (ret == 0)
         ret = memcmp(a->canon_enc, b->canon_enc, a->canon_enclen);
 
     return ret < 0 ? -1 : ret > 0;