]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
X509_NAME_cmp fix for empty name
authorWim Decroix <wim.decroix@auth0.com>
Thu, 8 Jun 2023 10:40:36 +0000 (12:40 +0200)
committerTomas Mraz <tomas@openssl.org>
Mon, 12 Jun 2023 13:26:11 +0000 (15:26 +0200)
CLA: trivial

Fixes #21156

Reviewed-by: Todd Short <todd.short@me.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/21155)

(cherry picked from commit ec59752835f616860cd9451d6cfcea16bfc3ad05)

crypto/x509/x509_cmp.c

index 5c9d91f4073d7480bc49f8a9ad516a368d645a35..c6e8ddab590d3a2f12264363443063c569bc3049 100644 (file)
@@ -277,11 +277,11 @@ int X509_NAME_cmp(const X509_NAME *a, const X509_NAME *b)
     if (ret == 0 && a->canon_enclen == 0)
         return 0;
 
-    if (a->canon_enc == NULL || b->canon_enc == NULL)
-        return -2;
-
-    if (ret == 0)
+    if (ret == 0) {
+        if (a->canon_enc == NULL || b->canon_enc == NULL)
+            return -2;
         ret = memcmp(a->canon_enc, b->canon_enc, a->canon_enclen);
+    }
 
     return ret < 0 ? -1 : ret > 0;
 }