summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authortb <>2022-01-05 07:29:47 +0000
committertb <>2022-01-05 07:29:47 +0000
commit89929e22962d742646fea54f6a21915e111903c8 (patch)
tree946eae5ed7ad523751934d54381feff427d3fc95 /src
parent7db6eebe2275424b4cc5d4a0e511766614000000 (diff)
downloadopenbsd-89929e22962d742646fea54f6a21915e111903c8.tar.gz
openbsd-89929e22962d742646fea54f6a21915e111903c8.tar.bz2
openbsd-89929e22962d742646fea54f6a21915e111903c8.zip
Readability tweaks in addr_contains()
Assign to local variables to avoid ugly line wrapping. ok inoguchi jsing
Diffstat (limited to 'src')
-rw-r--r--src/lib/libcrypto/x509/x509_addr.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/src/lib/libcrypto/x509/x509_addr.c b/src/lib/libcrypto/x509/x509_addr.c
index 92d540dbe5..80260dca10 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.59 2022/01/05 07:28:41 tb Exp $ */ 1/* $OpenBSD: x509_addr.c,v 1.60 2022/01/05 07:29:47 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").
@@ -1631,10 +1631,13 @@ X509v3_addr_inherits(IPAddrBlocks *addr)
1631 1631
1632/* 1632/*
1633 * Figure out whether parent contains child. 1633 * Figure out whether parent contains child.
1634 *
1635 * This only works correctly if both parent and child are in canonical form.
1634 */ 1636 */
1635static int 1637static int
1636addr_contains(IPAddressOrRanges *parent, IPAddressOrRanges *child, int length) 1638addr_contains(IPAddressOrRanges *parent, IPAddressOrRanges *child, int length)
1637{ 1639{
1640 IPAddressOrRange *aorc, *aorp;
1638 unsigned char p_min[ADDR_RAW_BUF_LEN], p_max[ADDR_RAW_BUF_LEN]; 1641 unsigned char p_min[ADDR_RAW_BUF_LEN], p_max[ADDR_RAW_BUF_LEN];
1639 unsigned char c_min[ADDR_RAW_BUF_LEN], c_max[ADDR_RAW_BUF_LEN]; 1642 unsigned char c_min[ADDR_RAW_BUF_LEN], c_max[ADDR_RAW_BUF_LEN];
1640 int p, c; 1643 int p, c;
@@ -1646,15 +1649,20 @@ addr_contains(IPAddressOrRanges *parent, IPAddressOrRanges *child, int length)
1646 1649
1647 p = 0; 1650 p = 0;
1648 for (c = 0; c < sk_IPAddressOrRange_num(child); c++) { 1651 for (c = 0; c < sk_IPAddressOrRange_num(child); c++) {
1649 if (!extract_min_max(sk_IPAddressOrRange_value(child, c), 1652 aorc = sk_IPAddressOrRange_value(child, c);
1650 c_min, c_max, length)) 1653
1654 if (!extract_min_max(aorc, c_min, c_max, length))
1651 return 0; 1655 return 0;
1656
1652 for (;; p++) { 1657 for (;; p++) {
1653 if (p >= sk_IPAddressOrRange_num(parent)) 1658 if (p >= sk_IPAddressOrRange_num(parent))
1654 return 0; 1659 return 0;
1655 if (!extract_min_max(sk_IPAddressOrRange_value(parent, 1660
1656 p), p_min, p_max, length)) 1661 aorp = sk_IPAddressOrRange_value(parent, p);
1662
1663 if (!extract_min_max(aorp, p_min, p_max, length))
1657 return 0; 1664 return 0;
1665
1658 if (memcmp(p_max, c_max, length) < 0) 1666 if (memcmp(p_max, c_max, length) < 0)
1659 continue; 1667 continue;
1660 if (memcmp(p_min, c_min, length) > 0) 1668 if (memcmp(p_min, c_min, length) > 0)