X509_NAME_cmp: if canon_enclen is 0 for both names return 0

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)
This commit is contained in:
Tomas Mraz 2021-04-12 09:58:27 +02:00
parent d32fc2c51b
commit 74bcbea76f

View 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;