summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/lib/libcrypto/x509/x509_addr.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/lib/libcrypto/x509/x509_addr.c b/src/lib/libcrypto/x509/x509_addr.c
index 705fc7df32..c6eac91aaa 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.61 2022/01/05 07:37:01 tb Exp $ */ 1/* $OpenBSD: x509_addr.c,v 1.62 2022/01/05 07:47:15 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").
@@ -755,6 +755,8 @@ v6IPAddressOrRange_cmp(const IPAddressOrRange *const *a,
755/* 755/*
756 * Calculate whether a range collapses to a prefix. 756 * Calculate whether a range collapses to a prefix.
757 * See last paragraph of RFC 3779 2.2.3.7. 757 * See last paragraph of RFC 3779 2.2.3.7.
758 *
759 * It's the caller's responsibility to ensure that min <= max.
758 */ 760 */
759static int 761static int
760range_should_be_prefix(const unsigned char *min, const unsigned char *max, 762range_should_be_prefix(const unsigned char *min, const unsigned char *max,
@@ -763,8 +765,6 @@ range_should_be_prefix(const unsigned char *min, const unsigned char *max,
763 unsigned char mask; 765 unsigned char mask;
764 int i, j; 766 int i, j;
765 767
766 if (memcmp(min, max, length) <= 0)
767 return -1;
768 for (i = 0; i < length && min[i] == max[i]; i++) 768 for (i = 0; i < length && min[i] == max[i]; i++)
769 continue; 769 continue;
770 for (j = length - 1; j >= 0 && min[j] == 0x00 && max[j] == 0xff; j--) 770 for (j = length - 1; j >= 0 && min[j] == 0x00 && max[j] == 0xff; j--)
@@ -863,6 +863,9 @@ make_addressRange(IPAddressOrRange **result, unsigned char *min,
863 IPAddressOrRange *aor; 863 IPAddressOrRange *aor;
864 int i, prefix_len; 864 int i, prefix_len;
865 865
866 if (memcmp(min, max, length) > 0)
867 return 0;
868
866 if ((prefix_len = range_should_be_prefix(min, max, length)) >= 0) 869 if ((prefix_len = range_should_be_prefix(min, max, length)) >= 0)
867 return make_addressPrefix(result, min, afi, prefix_len); 870 return make_addressPrefix(result, min, afi, prefix_len);
868 871