summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authortb <>2022-01-05 17:27:40 +0000
committertb <>2022-01-05 17:27:40 +0000
commit5cabdad28dc4f0eff24398d5fda161c2e7862a4a (patch)
treedd0e0343541991e33d02ac3c0e53b4c70ec8e218 /src/lib
parentf36e19daf334e48b7b56320dc79438974a09d2e5 (diff)
downloadopenbsd-5cabdad28dc4f0eff24398d5fda161c2e7862a4a.tar.gz
openbsd-5cabdad28dc4f0eff24398d5fda161c2e7862a4a.tar.bz2
openbsd-5cabdad28dc4f0eff24398d5fda161c2e7862a4a.zip
Move variable declarations in X509v3_addr_canonize() to the top of
the function and unindent some code. ok inoguchi jsing
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/libcrypto/x509/x509_addr.c36
1 files changed, 19 insertions, 17 deletions
diff --git a/src/lib/libcrypto/x509/x509_addr.c b/src/lib/libcrypto/x509/x509_addr.c
index c6eac91aaa..bee852d8db 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.62 2022/01/05 07:47:15 tb Exp $ */ 1/* $OpenBSD: x509_addr.c,v 1.63 2022/01/05 17:27:40 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").
@@ -1286,7 +1286,12 @@ X509v3_addr_is_canonical(IPAddrBlocks *addr)
1286static int 1286static int
1287IPAddressOrRanges_canonize(IPAddressOrRanges *aors, const unsigned afi) 1287IPAddressOrRanges_canonize(IPAddressOrRanges *aors, const unsigned afi)
1288{ 1288{
1289 int i, j, length = length_from_afi(afi); 1289 IPAddressOrRange *a, *b, *merged;
1290 unsigned char a_min[ADDR_RAW_BUF_LEN], a_max[ADDR_RAW_BUF_LEN];
1291 unsigned char b_min[ADDR_RAW_BUF_LEN], b_max[ADDR_RAW_BUF_LEN];
1292 int i, j, length;
1293
1294 length = length_from_afi(afi);
1290 1295
1291 /* 1296 /*
1292 * Sort the IPAddressOrRanges sequence. 1297 * Sort the IPAddressOrRanges sequence.
@@ -1297,10 +1302,8 @@ IPAddressOrRanges_canonize(IPAddressOrRanges *aors, const unsigned afi)
1297 * Clean up representation issues, punt on duplicates or overlaps. 1302 * Clean up representation issues, punt on duplicates or overlaps.
1298 */ 1303 */
1299 for (i = 0; i < sk_IPAddressOrRange_num(aors) - 1; i++) { 1304 for (i = 0; i < sk_IPAddressOrRange_num(aors) - 1; i++) {
1300 IPAddressOrRange *a = sk_IPAddressOrRange_value(aors, i); 1305 a = sk_IPAddressOrRange_value(aors, i);
1301 IPAddressOrRange *b = sk_IPAddressOrRange_value(aors, i + 1); 1306 b = sk_IPAddressOrRange_value(aors, i + 1);
1302 unsigned char a_min[ADDR_RAW_BUF_LEN], a_max[ADDR_RAW_BUF_LEN];
1303 unsigned char b_min[ADDR_RAW_BUF_LEN], b_max[ADDR_RAW_BUF_LEN];
1304 1307
1305 if (!extract_min_max(a, a_min, a_max, length) || 1308 if (!extract_min_max(a, a_min, a_max, length) ||
1306 !extract_min_max(b, b_min, b_max, length)) 1309 !extract_min_max(b, b_min, b_max, length))
@@ -1325,18 +1328,17 @@ IPAddressOrRanges_canonize(IPAddressOrRanges *aors, const unsigned afi)
1325 */ 1328 */
1326 for (j = length - 1; j >= 0 && b_min[j]-- == 0x00; j--) 1329 for (j = length - 1; j >= 0 && b_min[j]-- == 0x00; j--)
1327 continue; 1330 continue;
1328 if (memcmp(a_max, b_min, length) == 0) { 1331
1329 IPAddressOrRange *merged; 1332 if (memcmp(a_max, b_min, length) != 0)
1330 if (!make_addressRange(&merged, a_min, b_max, afi,
1331 length))
1332 return 0;
1333 (void)sk_IPAddressOrRange_set(aors, i, merged);
1334 (void)sk_IPAddressOrRange_delete(aors, i + 1);
1335 IPAddressOrRange_free(a);
1336 IPAddressOrRange_free(b);
1337 --i;
1338 continue; 1333 continue;
1339 } 1334
1335 if (!make_addressRange(&merged, a_min, b_max, afi, length))
1336 return 0;
1337 sk_IPAddressOrRange_set(aors, i, merged);
1338 sk_IPAddressOrRange_delete(aors, i + 1);
1339 IPAddressOrRange_free(a);
1340 IPAddressOrRange_free(b);
1341 i--;
1340 } 1342 }
1341 1343
1342 /* 1344 /*