summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/libcrypto/x509/x509_addr.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/lib/libcrypto/x509/x509_addr.c b/src/lib/libcrypto/x509/x509_addr.c
index f0ef5b8311..5f31d7307f 100644
--- a/src/lib/libcrypto/x509/x509_addr.c
+++ b/src/lib/libcrypto/x509/x509_addr.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: x509_addr.c,v 1.40 2021/12/28 19:59:33 tb Exp $ */ 1/* $OpenBSD: x509_addr.c,v 1.41 2021/12/28 20:07:17 tb Exp $ */
2/* 2/*
3 * Contributed to the OpenSSL Project by the American Registry for 3 * Contributed to the OpenSSL Project by the American Registry for
4 * Internet Numbers ("ARIN"). 4 * Internet Numbers ("ARIN").
@@ -1041,6 +1041,8 @@ X509v3_addr_get_range(IPAddressOrRange *aor, const unsigned afi,
1041 return afi_length; 1041 return afi_length;
1042} 1042}
1043 1043
1044#define MINIMUM(a, b) (((a) < (b)) ? (a) : (b))
1045
1044/* 1046/*
1045 * Sort comparison function for a sequence of IPAddressFamily. 1047 * Sort comparison function for a sequence of IPAddressFamily.
1046 * 1048 *
@@ -1057,9 +1059,14 @@ IPAddressFamily_cmp(const IPAddressFamily *const *a_,
1057{ 1059{
1058 const ASN1_OCTET_STRING *a = (*a_)->addressFamily; 1060 const ASN1_OCTET_STRING *a = (*a_)->addressFamily;
1059 const ASN1_OCTET_STRING *b = (*b_)->addressFamily; 1061 const ASN1_OCTET_STRING *b = (*b_)->addressFamily;
1060 int len = ((a->length <= b->length) ? a->length : b->length); 1062 int len, cmp;
1061 int cmp = memcmp(a->data, b->data, len); 1063
1062 return cmp ? cmp : a->length - b->length; 1064 len = MINIMUM(a->length, b->length);
1065
1066 if ((cmp = memcmp(a->data, b->data, len)) != 0)
1067 return cmp;
1068
1069 return a->length - b->length;
1063} 1070}
1064 1071
1065/* 1072/*