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