]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
Properly compare DNs when checking sorting
authorPierre Ossman <ossman@cendio.se>
Tue, 24 Mar 2020 14:29:34 +0000 (15:29 +0100)
committerPierre Ossman <ossman@cendio.se>
Fri, 3 Apr 2020 12:51:14 +0000 (14:51 +0200)
We might want to do other things than a simple memcmp() so make sure
we're using the right helper when comparing DNs.

Signed-off-by: Pierre Ossman <ossman@cendio.se>
lib/x509/common.c

index fbc7cc975fe59cc73533309b327740c52a4307f2..c8ea6657c73367cfb3a636e1da2c50e3a5f154f3 100644 (file)
@@ -1809,29 +1809,20 @@ gnutls_x509_crt_t *_gnutls_sort_clist(gnutls_x509_crt_t
 
 int _gnutls_check_if_sorted(gnutls_x509_crt_t * crt, int nr)
 {
-       void *prev_dn = NULL;
-       void *dn;
-       size_t prev_dn_size = 0, dn_size;
        int i, ret;
 
        /* check if the X.509 list is ordered */
        if (nr > 1) {
                for (i = 0; i < nr; i++) {
                        if (i > 0) {
-                               dn = crt[i]->raw_dn.data;
-                               dn_size = crt[i]->raw_dn.size;
-
-                               if (dn_size != prev_dn_size
-                                   || memcmp(dn, prev_dn, dn_size) != 0) {
+                               if (!_gnutls_x509_compare_raw_dn(&crt[i]->raw_dn,
+                                                                &crt[i-1]->raw_issuer_dn)) {
                                        ret =
                                            gnutls_assert_val
                                            (GNUTLS_E_CERTIFICATE_LIST_UNSORTED);
                                        goto cleanup;
                                }
                        }
-
-                       prev_dn = crt[i]->raw_issuer_dn.data;
-                       prev_dn_size = crt[i]->raw_issuer_dn.size;
                }
        }
        ret = 0;