diff options
author | Pierre Ossman <ossman@cendio.se> | 2020-03-24 15:29:34 +0100 |
---|---|---|
committer | Pierre Ossman <ossman@cendio.se> | 2020-04-03 14:51:14 +0200 |
commit | bbf7ed8b122b30c9951b11cb2e8c966769754147 (patch) | |
tree | 44de3e02fe4f6da530cd52929d6339adf1b91c57 | |
parent | f78524ae072ce8341cea9804585b9b614adac144 (diff) | |
download | gnutls-bbf7ed8b122b30c9951b11cb2e8c966769754147.tar.gz |
Properly compare DNs when checking sorting
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>
-rw-r--r-- | lib/x509/common.c | 13 |
1 files changed, 2 insertions, 11 deletions
diff --git a/lib/x509/common.c b/lib/x509/common.c index fbc7cc975f..c8ea6657c7 100644 --- a/lib/x509/common.c +++ b/lib/x509/common.c @@ -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; |