summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authortb <>2022-01-04 20:21:04 +0000
committertb <>2022-01-04 20:21:04 +0000
commit02d012a7f7c2102d9adcd13a330765989172924e (patch)
tree3eeb277c64dc47dbe306600c68513853bb7cca23 /src/lib
parent6da8a2384aedc4bf32ae2540bf15c32ff1f208fe (diff)
downloadopenbsd-02d012a7f7c2102d9adcd13a330765989172924e.tar.gz
openbsd-02d012a7f7c2102d9adcd13a330765989172924e.tar.bz2
openbsd-02d012a7f7c2102d9adcd13a330765989172924e.zip
Make X509v3_addr_get_range() readable.
Instead of checking everything in a single if statement, group the checks according to their purposes. ok inoguchi jsing
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/libcrypto/x509/x509_addr.c24
1 files changed, 17 insertions, 7 deletions
diff --git a/src/lib/libcrypto/x509/x509_addr.c b/src/lib/libcrypto/x509/x509_addr.c
index fdb2f64fd2..f6dbb3a9c1 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.52 2022/01/04 20:17:07 tb Exp $ */ 1/* $OpenBSD: x509_addr.c,v 1.53 2022/01/04 20:21:04 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").
@@ -1088,12 +1088,22 @@ int
1088X509v3_addr_get_range(IPAddressOrRange *aor, const unsigned afi, 1088X509v3_addr_get_range(IPAddressOrRange *aor, const unsigned afi,
1089 unsigned char *min, unsigned char *max, const int length) 1089 unsigned char *min, unsigned char *max, const int length)
1090{ 1090{
1091 int afi_length = length_from_afi(afi); 1091 int afi_length;
1092 if (aor == NULL || min == NULL || max == NULL || 1092
1093 afi_length == 0 || length < afi_length || 1093 if (aor == NULL || min == NULL || max == NULL)
1094 (aor->type != IPAddressOrRange_addressPrefix && 1094 return 0;
1095 aor->type != IPAddressOrRange_addressRange) || 1095
1096 !extract_min_max(aor, min, max, afi_length)) 1096 if ((afi_length = length_from_afi(afi)) == 0)
1097 return 0;
1098
1099 if (length < afi_length)
1100 return 0;
1101
1102 if (aor->type != IPAddressOrRange_addressPrefix &&
1103 aor->type != IPAddressOrRange_addressRange)
1104 return 0;
1105
1106 if (!extract_min_max(aor, min, max, afi_length))
1097 return 0; 1107 return 0;
1098 1108
1099 return afi_length; 1109 return afi_length;