| Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/openssl/src/crypto/x509v3/v3_addr.c |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||||||||||||||
| 2 | - | |||||||||||||||||||||||||
| 3 | - | |||||||||||||||||||||||||
| 4 | - | |||||||||||||||||||||||||
| 5 | - | |||||||||||||||||||||||||
| 6 | - | |||||||||||||||||||||||||
| 7 | - | |||||||||||||||||||||||||
| 8 | - | |||||||||||||||||||||||||
| 9 | - | |||||||||||||||||||||||||
| 10 | static const ASN1_TEMPLATE IPAddressRange_seq_tt[] = { | - | ||||||||||||||||||||||||
| 11 | { (0), (0), | - | ||||||||||||||||||||||||
| 12 | __builtin_offsetof ( | - | ||||||||||||||||||||||||
| 13 | IPAddressRange | - | ||||||||||||||||||||||||
| 14 | , | - | ||||||||||||||||||||||||
| 15 | min | - | ||||||||||||||||||||||||
| 16 | ) | - | ||||||||||||||||||||||||
| 17 | , "min", (&(ASN1_BIT_STRING_it)) }, | - | ||||||||||||||||||||||||
| 18 | { (0), (0), | - | ||||||||||||||||||||||||
| 19 | __builtin_offsetof ( | - | ||||||||||||||||||||||||
| 20 | IPAddressRange | - | ||||||||||||||||||||||||
| 21 | , | - | ||||||||||||||||||||||||
| 22 | max | - | ||||||||||||||||||||||||
| 23 | ) | - | ||||||||||||||||||||||||
| 24 | , "max", (&(ASN1_BIT_STRING_it)) } | - | ||||||||||||||||||||||||
| 25 | } ; const ASN1_ITEM IPAddressRange_it = { 0x1, 16, IPAddressRange_seq_tt, sizeof(IPAddressRange_seq_tt) / sizeof(ASN1_TEMPLATE), | - | ||||||||||||||||||||||||
| 26 | ((void *)0) | - | ||||||||||||||||||||||||
| 27 | , sizeof(IPAddressRange), "IPAddressRange" }; | - | ||||||||||||||||||||||||
| 28 | - | |||||||||||||||||||||||||
| 29 | static const ASN1_TEMPLATE IPAddressOrRange_ch_tt[] = { | - | ||||||||||||||||||||||||
| 30 | { (0), (0), | - | ||||||||||||||||||||||||
| 31 | __builtin_offsetof ( | - | ||||||||||||||||||||||||
| 32 | IPAddressOrRange | - | ||||||||||||||||||||||||
| 33 | , | - | ||||||||||||||||||||||||
| 34 | u.addressPrefix | - | ||||||||||||||||||||||||
| 35 | ) | - | ||||||||||||||||||||||||
| 36 | , "u.addressPrefix", (&(ASN1_BIT_STRING_it)) }, | - | ||||||||||||||||||||||||
| 37 | { (0), (0), | - | ||||||||||||||||||||||||
| 38 | __builtin_offsetof ( | - | ||||||||||||||||||||||||
| 39 | IPAddressOrRange | - | ||||||||||||||||||||||||
| 40 | , | - | ||||||||||||||||||||||||
| 41 | u.addressRange | - | ||||||||||||||||||||||||
| 42 | ) | - | ||||||||||||||||||||||||
| 43 | , "u.addressRange", (&(IPAddressRange_it)) } | - | ||||||||||||||||||||||||
| 44 | } ; const ASN1_ITEM IPAddressOrRange_it = { 0x2, | - | ||||||||||||||||||||||||
| 45 | __builtin_offsetof ( | - | ||||||||||||||||||||||||
| 46 | IPAddressOrRange | - | ||||||||||||||||||||||||
| 47 | , | - | ||||||||||||||||||||||||
| 48 | type | - | ||||||||||||||||||||||||
| 49 | ) | - | ||||||||||||||||||||||||
| 50 | , IPAddressOrRange_ch_tt, sizeof(IPAddressOrRange_ch_tt) / sizeof(ASN1_TEMPLATE), | - | ||||||||||||||||||||||||
| 51 | ((void *)0) | - | ||||||||||||||||||||||||
| 52 | , sizeof(IPAddressOrRange), "IPAddressOrRange" }; | - | ||||||||||||||||||||||||
| 53 | - | |||||||||||||||||||||||||
| 54 | static const ASN1_TEMPLATE IPAddressChoice_ch_tt[] = { | - | ||||||||||||||||||||||||
| 55 | { (0), (0), | - | ||||||||||||||||||||||||
| 56 | __builtin_offsetof ( | - | ||||||||||||||||||||||||
| 57 | IPAddressChoice | - | ||||||||||||||||||||||||
| 58 | , | - | ||||||||||||||||||||||||
| 59 | u.inherit | - | ||||||||||||||||||||||||
| 60 | ) | - | ||||||||||||||||||||||||
| 61 | , "u.inherit", (&(ASN1_NULL_it)) }, | - | ||||||||||||||||||||||||
| 62 | { ((0x2 << 1)), (0), | - | ||||||||||||||||||||||||
| 63 | __builtin_offsetof ( | - | ||||||||||||||||||||||||
| 64 | IPAddressChoice | - | ||||||||||||||||||||||||
| 65 | , | - | ||||||||||||||||||||||||
| 66 | u.addressesOrRanges | - | ||||||||||||||||||||||||
| 67 | ) | - | ||||||||||||||||||||||||
| 68 | , "u.addressesOrRanges", (&(IPAddressOrRange_it)) } | - | ||||||||||||||||||||||||
| 69 | } ; const ASN1_ITEM IPAddressChoice_it = { 0x2, | - | ||||||||||||||||||||||||
| 70 | __builtin_offsetof ( | - | ||||||||||||||||||||||||
| 71 | IPAddressChoice | - | ||||||||||||||||||||||||
| 72 | , | - | ||||||||||||||||||||||||
| 73 | type | - | ||||||||||||||||||||||||
| 74 | ) | - | ||||||||||||||||||||||||
| 75 | , IPAddressChoice_ch_tt, sizeof(IPAddressChoice_ch_tt) / sizeof(ASN1_TEMPLATE), | - | ||||||||||||||||||||||||
| 76 | ((void *)0) | - | ||||||||||||||||||||||||
| 77 | , sizeof(IPAddressChoice), "IPAddressChoice" }; | - | ||||||||||||||||||||||||
| 78 | - | |||||||||||||||||||||||||
| 79 | static const ASN1_TEMPLATE IPAddressFamily_seq_tt[] = { | - | ||||||||||||||||||||||||
| 80 | { (0), (0), | - | ||||||||||||||||||||||||
| 81 | __builtin_offsetof ( | - | ||||||||||||||||||||||||
| 82 | IPAddressFamily | - | ||||||||||||||||||||||||
| 83 | , | - | ||||||||||||||||||||||||
| 84 | addressFamily | - | ||||||||||||||||||||||||
| 85 | ) | - | ||||||||||||||||||||||||
| 86 | , "addressFamily", (&(ASN1_OCTET_STRING_it)) }, | - | ||||||||||||||||||||||||
| 87 | { (0), (0), | - | ||||||||||||||||||||||||
| 88 | __builtin_offsetof ( | - | ||||||||||||||||||||||||
| 89 | IPAddressFamily | - | ||||||||||||||||||||||||
| 90 | , | - | ||||||||||||||||||||||||
| 91 | ipAddressChoice | - | ||||||||||||||||||||||||
| 92 | ) | - | ||||||||||||||||||||||||
| 93 | , "ipAddressChoice", (&(IPAddressChoice_it)) } | - | ||||||||||||||||||||||||
| 94 | } ; const ASN1_ITEM IPAddressFamily_it = { 0x1, 16, IPAddressFamily_seq_tt, sizeof(IPAddressFamily_seq_tt) / sizeof(ASN1_TEMPLATE), | - | ||||||||||||||||||||||||
| 95 | ((void *)0) | - | ||||||||||||||||||||||||
| 96 | , sizeof(IPAddressFamily), "IPAddressFamily" }; | - | ||||||||||||||||||||||||
| 97 | - | |||||||||||||||||||||||||
| 98 | static const ASN1_TEMPLATE IPAddrBlocks_item_tt = | - | ||||||||||||||||||||||||
| 99 | { ((0x2 << 1)), (0), 0, "IPAddrBlocks", (&(IPAddressFamily_it)) } | - | ||||||||||||||||||||||||
| 100 | - | |||||||||||||||||||||||||
| 101 | ; static const ASN1_ITEM IPAddrBlocks_it = { 0x0, -1, &IPAddrBlocks_item_tt, 0, | - | ||||||||||||||||||||||||
| 102 | ((void *)0) | - | ||||||||||||||||||||||||
| 103 | , 0, "IPAddrBlocks" }; | - | ||||||||||||||||||||||||
| 104 | - | |||||||||||||||||||||||||
| 105 | IPAddressRange *d2i_IPAddressRange(IPAddressRange **a, const unsigned char **in, long len) { return never executed: (IPAddressRange *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, (&(IPAddressRange_it)));return (IPAddressRange *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, (&(IPAddressRange_it)));never executed: } int i2d_IPAddressRange(IPAddressRange *a, unsigned char **out) { returnreturn (IPAddressRange *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, (&(IPAddressRange_it)));never executed: ASN1_item_i2d((ASN1_VALUE *)a, out, (&(IPAddressRange_it)));return ASN1_item_i2d((ASN1_VALUE *)a, out, (&(IPAddressRange_it)));never executed: } IPAddressRange *IPAddressRange_new(void) { returnreturn ASN1_item_i2d((ASN1_VALUE *)a, out, (&(IPAddressRange_it)));never executed: (IPAddressRange *)ASN1_item_new((&(IPAddressRange_it)));return (IPAddressRange *)ASN1_item_new((&(IPAddressRange_it)));never executed: } void IPAddressRange_free(IPAddressRange *a) { ASN1_item_free((ASN1_VALUE *)a, (&(IPAddressRange_it))); }return (IPAddressRange *)ASN1_item_new((&(IPAddressRange_it)));never executed: end of block | 0 | ||||||||||||||||||||||||
| 106 | IPAddressOrRange *d2i_IPAddressOrRange(IPAddressOrRange **a, const unsigned char **in, long len) { return never executed: (IPAddressOrRange *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, (&(IPAddressOrRange_it)));return (IPAddressOrRange *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, (&(IPAddressOrRange_it)));never executed: } int i2d_IPAddressOrRange(IPAddressOrRange *a, unsigned char **out) { returnreturn (IPAddressOrRange *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, (&(IPAddressOrRange_it)));never executed: ASN1_item_i2d((ASN1_VALUE *)a, out, (&(IPAddressOrRange_it)));return ASN1_item_i2d((ASN1_VALUE *)a, out, (&(IPAddressOrRange_it)));never executed: } IPAddressOrRange *IPAddressOrRange_new(void) { returnreturn ASN1_item_i2d((ASN1_VALUE *)a, out, (&(IPAddressOrRange_it)));never executed: (IPAddressOrRange *)ASN1_item_new((&(IPAddressOrRange_it)));return (IPAddressOrRange *)ASN1_item_new((&(IPAddressOrRange_it)));never executed: } void IPAddressOrRange_free(IPAddressOrRange *a) { ASN1_item_free((ASN1_VALUE *)a, (&(IPAddressOrRange_it))); }return (IPAddressOrRange *)ASN1_item_new((&(IPAddressOrRange_it)));never executed: end of block | 0 | ||||||||||||||||||||||||
| 107 | IPAddressChoice *d2i_IPAddressChoice(IPAddressChoice **a, const unsigned char **in, long len) { return never executed: (IPAddressChoice *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, (&(IPAddressChoice_it)));return (IPAddressChoice *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, (&(IPAddressChoice_it)));never executed: } int i2d_IPAddressChoice(IPAddressChoice *a, unsigned char **out) { returnreturn (IPAddressChoice *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, (&(IPAddressChoice_it)));never executed: ASN1_item_i2d((ASN1_VALUE *)a, out, (&(IPAddressChoice_it)));return ASN1_item_i2d((ASN1_VALUE *)a, out, (&(IPAddressChoice_it)));never executed: } IPAddressChoice *IPAddressChoice_new(void) { returnreturn ASN1_item_i2d((ASN1_VALUE *)a, out, (&(IPAddressChoice_it)));never executed: (IPAddressChoice *)ASN1_item_new((&(IPAddressChoice_it)));return (IPAddressChoice *)ASN1_item_new((&(IPAddressChoice_it)));never executed: } void IPAddressChoice_free(IPAddressChoice *a) { ASN1_item_free((ASN1_VALUE *)a, (&(IPAddressChoice_it))); }return (IPAddressChoice *)ASN1_item_new((&(IPAddressChoice_it)));never executed: end of block | 0 | ||||||||||||||||||||||||
| 108 | IPAddressFamily *d2i_IPAddressFamily(IPAddressFamily **a, const unsigned char **in, long len) { return never executed: (IPAddressFamily *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, (&(IPAddressFamily_it)));return (IPAddressFamily *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, (&(IPAddressFamily_it)));never executed: } int i2d_IPAddressFamily(IPAddressFamily *a, unsigned char **out) { returnreturn (IPAddressFamily *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, (&(IPAddressFamily_it)));never executed: ASN1_item_i2d((ASN1_VALUE *)a, out, (&(IPAddressFamily_it)));return ASN1_item_i2d((ASN1_VALUE *)a, out, (&(IPAddressFamily_it)));never executed: } IPAddressFamily *IPAddressFamily_new(void) { returnreturn ASN1_item_i2d((ASN1_VALUE *)a, out, (&(IPAddressFamily_it)));never executed: (IPAddressFamily *)ASN1_item_new((&(IPAddressFamily_it)));return (IPAddressFamily *)ASN1_item_new((&(IPAddressFamily_it)));never executed: } void IPAddressFamily_free(IPAddressFamily *a) { ASN1_item_free((ASN1_VALUE *)a, (&(IPAddressFamily_it))); }return (IPAddressFamily *)ASN1_item_new((&(IPAddressFamily_it)));never executed: end of block | 0 | ||||||||||||||||||||||||
| 109 | static int length_from_afi(const unsigned afi) | - | ||||||||||||||||||||||||
| 110 | { | - | ||||||||||||||||||||||||
| 111 | switch (afi) { | - | ||||||||||||||||||||||||
| 112 | case never executed: 1:case 1:never executed: case 1: | 0 | ||||||||||||||||||||||||
| 113 | return never executed: 4;return 4;never executed: return 4; | 0 | ||||||||||||||||||||||||
| 114 | case never executed: 2:case 2:never executed: case 2: | 0 | ||||||||||||||||||||||||
| 115 | return never executed: 16;return 16;never executed: return 16; | 0 | ||||||||||||||||||||||||
| 116 | default never executed: :default:never executed: default: | 0 | ||||||||||||||||||||||||
| 117 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 118 | } | - | ||||||||||||||||||||||||
| 119 | } | - | ||||||||||||||||||||||||
| 120 | - | |||||||||||||||||||||||||
| 121 | - | |||||||||||||||||||||||||
| 122 | - | |||||||||||||||||||||||||
| 123 | - | |||||||||||||||||||||||||
| 124 | unsigned int X509v3_addr_get_afi(const IPAddressFamily *f) | - | ||||||||||||||||||||||||
| 125 | { | - | ||||||||||||||||||||||||
| 126 | if (f ==
| 0-360 | ||||||||||||||||||||||||
| 127 | ((void *)0)
| 0-360 | ||||||||||||||||||||||||
| 128 | - | |||||||||||||||||||||||||
| 129 | || f->addressFamily ==
| 0-360 | ||||||||||||||||||||||||
| 130 | ((void *)0)
| 0-360 | ||||||||||||||||||||||||
| 131 | - | |||||||||||||||||||||||||
| 132 | || f->addressFamily->data ==
| 0-360 | ||||||||||||||||||||||||
| 133 | ((void *)0)
| 0-360 | ||||||||||||||||||||||||
| 134 | - | |||||||||||||||||||||||||
| 135 | || f->addressFamily->length < 2
| 10-350 | ||||||||||||||||||||||||
| 136 | return executed 10 times by 1 test: 0;return 0;Executed by:
executed 10 times by 1 test: return 0;Executed by:
| 10 | ||||||||||||||||||||||||
| 137 | return executed 350 times by 1 test: (f->addressFamily->data[0] << 8) | f->addressFamily->data[1];return (f->addressFamily->data[0] << 8) | f->addressFamily->data[1];Executed by:
executed 350 times by 1 test: return (f->addressFamily->data[0] << 8) | f->addressFamily->data[1];Executed by:
| 350 | ||||||||||||||||||||||||
| 138 | } | - | ||||||||||||||||||||||||
| 139 | - | |||||||||||||||||||||||||
| 140 | - | |||||||||||||||||||||||||
| 141 | - | |||||||||||||||||||||||||
| 142 | - | |||||||||||||||||||||||||
| 143 | - | |||||||||||||||||||||||||
| 144 | static int addr_expand(unsigned char *addr, | - | ||||||||||||||||||||||||
| 145 | const ASN1_BIT_STRING *bs, | - | ||||||||||||||||||||||||
| 146 | const int length, const unsigned char fill) | - | ||||||||||||||||||||||||
| 147 | { | - | ||||||||||||||||||||||||
| 148 | if (bs->length < 0
| 0-458 | ||||||||||||||||||||||||
| 149 | return executed 21 times by 1 test: 0;return 0;Executed by:
executed 21 times by 1 test: return 0;Executed by:
| 21 | ||||||||||||||||||||||||
| 150 | if (bs->length > 0
| 14-423 | ||||||||||||||||||||||||
| 151 | memcpy(addr, bs->data, bs->length); | - | ||||||||||||||||||||||||
| 152 | if ((
| 130-293 | ||||||||||||||||||||||||
| 153 | unsigned char mask = 0xFF >> (8 - (bs->flags & 7)); | - | ||||||||||||||||||||||||
| 154 | if (fill == 0
| 17-276 | ||||||||||||||||||||||||
| 155 | addr[bs->length - 1] &= ~mask; executed 276 times by 1 test: addr[bs->length - 1] &= ~mask;Executed by:
| 276 | ||||||||||||||||||||||||
| 156 | else | - | ||||||||||||||||||||||||
| 157 | addr[bs->length - 1] |= mask; executed 17 times by 1 test: addr[bs->length - 1] |= mask;Executed by:
| 17 | ||||||||||||||||||||||||
| 158 | } | - | ||||||||||||||||||||||||
| 159 | } executed 423 times by 1 test: end of blockExecuted by:
| 423 | ||||||||||||||||||||||||
| 160 | memset(addr + bs->length, fill, length - bs->length); | - | ||||||||||||||||||||||||
| 161 | return executed 437 times by 1 test: 1;return 1;Executed by:
executed 437 times by 1 test: return 1;Executed by:
| 437 | ||||||||||||||||||||||||
| 162 | } | - | ||||||||||||||||||||||||
| 163 | static int i2r_address(BIO *out, | - | ||||||||||||||||||||||||
| 164 | const unsigned afi, | - | ||||||||||||||||||||||||
| 165 | const unsigned char fill, const ASN1_BIT_STRING *bs) | - | ||||||||||||||||||||||||
| 166 | { | - | ||||||||||||||||||||||||
| 167 | unsigned char addr[16]; | - | ||||||||||||||||||||||||
| 168 | int i, n; | - | ||||||||||||||||||||||||
| 169 | - | |||||||||||||||||||||||||
| 170 | if (bs->length < 0
| 0-679 | ||||||||||||||||||||||||
| 171 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 172 | switch (afi) { | - | ||||||||||||||||||||||||
| 173 | case executed 88 times by 1 test: 1:case 1:Executed by:
executed 88 times by 1 test: case 1:Executed by:
| 88 | ||||||||||||||||||||||||
| 174 | if (!addr_expand(addr, bs, 4, fill)
| 11-77 | ||||||||||||||||||||||||
| 175 | return executed 11 times by 1 test: 0;return 0;Executed by:
executed 11 times by 1 test: return 0;Executed by:
| 11 | ||||||||||||||||||||||||
| 176 | BIO_printf(out, "%d.%d.%d.%d", addr[0], addr[1], addr[2], addr[3]); | - | ||||||||||||||||||||||||
| 177 | break; executed 77 times by 1 test: break;Executed by:
| 77 | ||||||||||||||||||||||||
| 178 | case executed 370 times by 1 test: 2:case 2:Executed by:
executed 370 times by 1 test: case 2:Executed by:
| 370 | ||||||||||||||||||||||||
| 179 | if (!addr_expand(addr, bs, 16, fill)
| 10-360 | ||||||||||||||||||||||||
| 180 | return executed 10 times by 1 test: 0;return 0;Executed by:
executed 10 times by 1 test: return 0;Executed by:
| 10 | ||||||||||||||||||||||||
| 181 | for (n = 16; n > 1
| 22-1969 | ||||||||||||||||||||||||
| 182 | n -= 2) ; executed 1631 times by 1 test: ;Executed by:
| 1631 | ||||||||||||||||||||||||
| 183 | for (i = 0; i < n
| 360-1249 | ||||||||||||||||||||||||
| 184 | BIO_printf(out, "%x%s", (addr[i] << 8) | addr[i + 1], executed 1249 times by 1 test: BIO_printf(out, "%x%s", (addr[i] << 8) | addr[i + 1], (i < 14 ? ":" : ""));Executed by:
| 1249 | ||||||||||||||||||||||||
| 185 | (i < 14 ? ":" : "")); executed 1249 times by 1 test: BIO_printf(out, "%x%s", (addr[i] << 8) | addr[i + 1], (i < 14 ? ":" : ""));Executed by:
| 1249 | ||||||||||||||||||||||||
| 186 | if (i < 16
| 43-317 | ||||||||||||||||||||||||
| 187 | BIO_puts(out, ":"); executed 317 times by 1 test: BIO_puts(out, ":");Executed by:
| 317 | ||||||||||||||||||||||||
| 188 | if (i == 0
| 22-338 | ||||||||||||||||||||||||
| 189 | BIO_puts(out, ":"); executed 22 times by 1 test: BIO_puts(out, ":");Executed by:
| 22 | ||||||||||||||||||||||||
| 190 | break; executed 360 times by 1 test: break;Executed by:
| 360 | ||||||||||||||||||||||||
| 191 | default executed 221 times by 1 test: :default:Executed by:
executed 221 times by 1 test: default:Executed by:
| 221 | ||||||||||||||||||||||||
| 192 | for (i = 0; i < bs->length
| 221-1433 | ||||||||||||||||||||||||
| 193 | BIO_printf(out, "%s%02x", (i > 0 ? ":" : ""), bs->data[i]); executed 1433 times by 1 test: BIO_printf(out, "%s%02x", (i > 0 ? ":" : ""), bs->data[i]);Executed by:
| 1433 | ||||||||||||||||||||||||
| 194 | BIO_printf(out, "[%d]", (int)(bs->flags & 7)); | - | ||||||||||||||||||||||||
| 195 | break; executed 221 times by 1 test: break;Executed by:
| 221 | ||||||||||||||||||||||||
| 196 | } | - | ||||||||||||||||||||||||
| 197 | return executed 658 times by 1 test: 1;return 1;Executed by:
executed 658 times by 1 test: return 1;Executed by:
| 658 | ||||||||||||||||||||||||
| 198 | } | - | ||||||||||||||||||||||||
| 199 | - | |||||||||||||||||||||||||
| 200 | - | |||||||||||||||||||||||||
| 201 | - | |||||||||||||||||||||||||
| 202 | - | |||||||||||||||||||||||||
| 203 | static int i2r_IPAddressOrRanges(BIO *out, | - | ||||||||||||||||||||||||
| 204 | const int indent, | - | ||||||||||||||||||||||||
| 205 | const IPAddressOrRanges *aors, | - | ||||||||||||||||||||||||
| 206 | const unsigned afi) | - | ||||||||||||||||||||||||
| 207 | { | - | ||||||||||||||||||||||||
| 208 | int i; | - | ||||||||||||||||||||||||
| 209 | for (i = 0; i < sk_IPAddressOrRange_num(aors)
| 292-574 | ||||||||||||||||||||||||
| 210 | const IPAddressOrRange *aor = sk_IPAddressOrRange_value(aors, i); | - | ||||||||||||||||||||||||
| 211 | BIO_printf(out, "%*s", indent, ""); | - | ||||||||||||||||||||||||
| 212 | switch (aor->type) { | - | ||||||||||||||||||||||||
| 213 | case executed 464 times by 1 test: 0:case 0:Executed by:
executed 464 times by 1 test: case 0:Executed by:
| 464 | ||||||||||||||||||||||||
| 214 | if (!i2r_address(out, afi, 0x00, aor->u.addressPrefix)
| 13-451 | ||||||||||||||||||||||||
| 215 | return executed 13 times by 1 test: 0;return 0;Executed by:
executed 13 times by 1 test: return 0;Executed by:
| 13 | ||||||||||||||||||||||||
| 216 | BIO_printf(out, "/%d\n", ((int) ((aor->u.addressPrefix)->length * 8 - ((aor->u.addressPrefix)->flags & 7)))); | - | ||||||||||||||||||||||||
| 217 | continue; executed 451 times by 1 test: continue;Executed by:
| 451 | ||||||||||||||||||||||||
| 218 | case executed 110 times by 1 test: 1:case 1:Executed by:
executed 110 times by 1 test: case 1:Executed by:
| 110 | ||||||||||||||||||||||||
| 219 | if (!i2r_address(out, afi, 0x00, aor->u.addressRange->min)
| 5-105 | ||||||||||||||||||||||||
| 220 | return executed 5 times by 1 test: 0;return 0;Executed by:
executed 5 times by 1 test: return 0;Executed by:
| 5 | ||||||||||||||||||||||||
| 221 | BIO_puts(out, "-"); | - | ||||||||||||||||||||||||
| 222 | if (!i2r_address(out, afi, 0xFF, aor->u.addressRange->max)
| 3-102 | ||||||||||||||||||||||||
| 223 | return executed 3 times by 1 test: 0;return 0;Executed by:
executed 3 times by 1 test: return 0;Executed by:
| 3 | ||||||||||||||||||||||||
| 224 | BIO_puts(out, "\n"); | - | ||||||||||||||||||||||||
| 225 | continue; executed 102 times by 1 test: continue;Executed by:
| 102 | ||||||||||||||||||||||||
| 226 | } | - | ||||||||||||||||||||||||
| 227 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 228 | return executed 292 times by 1 test: 1;return 1;Executed by:
executed 292 times by 1 test: return 1;Executed by:
| 292 | ||||||||||||||||||||||||
| 229 | } | - | ||||||||||||||||||||||||
| 230 | - | |||||||||||||||||||||||||
| 231 | - | |||||||||||||||||||||||||
| 232 | - | |||||||||||||||||||||||||
| 233 | - | |||||||||||||||||||||||||
| 234 | static int i2r_IPAddrBlocks(const X509V3_EXT_METHOD *method, | - | ||||||||||||||||||||||||
| 235 | void *ext, BIO *out, int indent) | - | ||||||||||||||||||||||||
| 236 | { | - | ||||||||||||||||||||||||
| 237 | const IPAddrBlocks *addr = ext; | - | ||||||||||||||||||||||||
| 238 | int i; | - | ||||||||||||||||||||||||
| 239 | for (i = 0; i < sk_IPAddressFamily_num(addr)
| 159-360 | ||||||||||||||||||||||||
| 240 | IPAddressFamily *f = sk_IPAddressFamily_value(addr, i); | - | ||||||||||||||||||||||||
| 241 | const unsigned int afi = X509v3_addr_get_afi(f); | - | ||||||||||||||||||||||||
| 242 | switch (afi) { | - | ||||||||||||||||||||||||
| 243 | case executed 35 times by 1 test: 1:case 1:Executed by:
executed 35 times by 1 test: case 1:Executed by:
| 35 | ||||||||||||||||||||||||
| 244 | BIO_printf(out, "%*sIPv4", indent, ""); | - | ||||||||||||||||||||||||
| 245 | break; executed 35 times by 1 test: break;Executed by:
| 35 | ||||||||||||||||||||||||
| 246 | case executed 205 times by 1 test: 2:case 2:Executed by:
executed 205 times by 1 test: case 2:Executed by:
| 205 | ||||||||||||||||||||||||
| 247 | BIO_printf(out, "%*sIPv6", indent, ""); | - | ||||||||||||||||||||||||
| 248 | break; executed 205 times by 1 test: break;Executed by:
| 205 | ||||||||||||||||||||||||
| 249 | default executed 120 times by 1 test: :default:Executed by:
executed 120 times by 1 test: default:Executed by:
| 120 | ||||||||||||||||||||||||
| 250 | BIO_printf(out, "%*sUnknown AFI %u", indent, "", afi); | - | ||||||||||||||||||||||||
| 251 | break; executed 120 times by 1 test: break;Executed by:
| 120 | ||||||||||||||||||||||||
| 252 | } | - | ||||||||||||||||||||||||
| 253 | if (f->addressFamily->length > 2
| 165-195 | ||||||||||||||||||||||||
| 254 | switch (f->addressFamily->data[2]) { | - | ||||||||||||||||||||||||
| 255 | case executed 11 times by 1 test: 1:case 1:Executed by:
executed 11 times by 1 test: case 1:Executed by:
| 11 | ||||||||||||||||||||||||
| 256 | BIO_puts(out, " (Unicast)"); | - | ||||||||||||||||||||||||
| 257 | break; executed 11 times by 1 test: break;Executed by:
| 11 | ||||||||||||||||||||||||
| 258 | case executed 13 times by 1 test: 2:case 2:Executed by:
executed 13 times by 1 test: case 2:Executed by:
| 13 | ||||||||||||||||||||||||
| 259 | BIO_puts(out, " (Multicast)"); | - | ||||||||||||||||||||||||
| 260 | break; executed 13 times by 1 test: break;Executed by:
| 13 | ||||||||||||||||||||||||
| 261 | case executed 16 times by 1 test: 3:case 3:Executed by:
executed 16 times by 1 test: case 3:Executed by:
| 16 | ||||||||||||||||||||||||
| 262 | BIO_puts(out, " (Unicast/Multicast)"); | - | ||||||||||||||||||||||||
| 263 | break; executed 16 times by 1 test: break;Executed by:
| 16 | ||||||||||||||||||||||||
| 264 | case executed 46 times by 1 test: 4:case 4:Executed by:
executed 46 times by 1 test: case 4:Executed by:
| 46 | ||||||||||||||||||||||||
| 265 | BIO_puts(out, " (MPLS)"); | - | ||||||||||||||||||||||||
| 266 | break; executed 46 times by 1 test: break;Executed by:
| 46 | ||||||||||||||||||||||||
| 267 | case executed 10 times by 1 test: 64:case 64:Executed by:
executed 10 times by 1 test: case 64:Executed by:
| 10 | ||||||||||||||||||||||||
| 268 | BIO_puts(out, " (Tunnel)"); | - | ||||||||||||||||||||||||
| 269 | break; executed 10 times by 1 test: break;Executed by:
| 10 | ||||||||||||||||||||||||
| 270 | case executed 24 times by 1 test: 65:case 65:Executed by:
executed 24 times by 1 test: case 65:Executed by:
| 24 | ||||||||||||||||||||||||
| 271 | BIO_puts(out, " (VPLS)"); | - | ||||||||||||||||||||||||
| 272 | break; executed 24 times by 1 test: break;Executed by:
| 24 | ||||||||||||||||||||||||
| 273 | case executed 10 times by 1 test: 66:case 66:Executed by:
executed 10 times by 1 test: case 66:Executed by:
| 10 | ||||||||||||||||||||||||
| 274 | BIO_puts(out, " (BGP MDT)"); | - | ||||||||||||||||||||||||
| 275 | break; executed 10 times by 1 test: break;Executed by:
| 10 | ||||||||||||||||||||||||
| 276 | case executed 10 times by 1 test: 128:case 128:Executed by:
executed 10 times by 1 test: case 128:Executed by:
| 10 | ||||||||||||||||||||||||
| 277 | BIO_puts(out, " (MPLS-labeled VPN)"); | - | ||||||||||||||||||||||||
| 278 | break; executed 10 times by 1 test: break;Executed by:
| 10 | ||||||||||||||||||||||||
| 279 | default executed 55 times by 1 test: :default:Executed by:
executed 55 times by 1 test: default:Executed by:
| 55 | ||||||||||||||||||||||||
| 280 | BIO_printf(out, " (Unknown SAFI %u)", | - | ||||||||||||||||||||||||
| 281 | (unsigned)f->addressFamily->data[2]); | - | ||||||||||||||||||||||||
| 282 | break; executed 55 times by 1 test: break;Executed by:
| 55 | ||||||||||||||||||||||||
| 283 | } | - | ||||||||||||||||||||||||
| 284 | } | - | ||||||||||||||||||||||||
| 285 | switch (f->ipAddressChoice->type) { | - | ||||||||||||||||||||||||
| 286 | case executed 47 times by 1 test: 0:case 0:Executed by:
executed 47 times by 1 test: case 0:Executed by:
| 47 | ||||||||||||||||||||||||
| 287 | BIO_puts(out, ": inherit\n"); | - | ||||||||||||||||||||||||
| 288 | break; executed 47 times by 1 test: break;Executed by:
| 47 | ||||||||||||||||||||||||
| 289 | case executed 313 times by 1 test: 1:case 1:Executed by:
executed 313 times by 1 test: case 1:Executed by:
| 313 | ||||||||||||||||||||||||
| 290 | BIO_puts(out, ":\n"); | - | ||||||||||||||||||||||||
| 291 | if (!i2r_IPAddressOrRanges(out,
| 21-292 | ||||||||||||||||||||||||
| 292 | indent + 2,
| 21-292 | ||||||||||||||||||||||||
| 293 | f->ipAddressChoice->
| 21-292 | ||||||||||||||||||||||||
| 294 | u.addressesOrRanges, afi)
| 21-292 | ||||||||||||||||||||||||
| 295 | return executed 21 times by 1 test: 0;return 0;Executed by:
executed 21 times by 1 test: return 0;Executed by:
| 21 | ||||||||||||||||||||||||
| 296 | break; executed 292 times by 1 test: break;Executed by:
| 292 | ||||||||||||||||||||||||
| 297 | } | - | ||||||||||||||||||||||||
| 298 | } executed 339 times by 1 test: end of blockExecuted by:
| 339 | ||||||||||||||||||||||||
| 299 | return executed 159 times by 1 test: 1;return 1;Executed by:
executed 159 times by 1 test: return 1;Executed by:
| 159 | ||||||||||||||||||||||||
| 300 | } | - | ||||||||||||||||||||||||
| 301 | static int IPAddressOrRange_cmp(const IPAddressOrRange *a, | - | ||||||||||||||||||||||||
| 302 | const IPAddressOrRange *b, const int length) | - | ||||||||||||||||||||||||
| 303 | { | - | ||||||||||||||||||||||||
| 304 | unsigned char addr_a[16], addr_b[16]; | - | ||||||||||||||||||||||||
| 305 | int prefixlen_a = 0, prefixlen_b = 0; | - | ||||||||||||||||||||||||
| 306 | int r; | - | ||||||||||||||||||||||||
| 307 | - | |||||||||||||||||||||||||
| 308 | switch (a->type) { | - | ||||||||||||||||||||||||
| 309 | case never executed: 0:case 0:never executed: case 0: | 0 | ||||||||||||||||||||||||
| 310 | if (!addr_expand(addr_a, a->u.addressPrefix, length, 0x00)
| 0 | ||||||||||||||||||||||||
| 311 | return never executed: -1;return -1;never executed: return -1; | 0 | ||||||||||||||||||||||||
| 312 | prefixlen_a = ((int) ((a->u.addressPrefix)->length * 8 - ((a->u.addressPrefix)->flags & 7))); | - | ||||||||||||||||||||||||
| 313 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 314 | case never executed: 1:case 1:never executed: case 1: | 0 | ||||||||||||||||||||||||
| 315 | if (!addr_expand(addr_a, a->u.addressRange->min, length, 0x00)
| 0 | ||||||||||||||||||||||||
| 316 | return never executed: -1;return -1;never executed: return -1; | 0 | ||||||||||||||||||||||||
| 317 | prefixlen_a = length * 8; | - | ||||||||||||||||||||||||
| 318 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 319 | } | - | ||||||||||||||||||||||||
| 320 | - | |||||||||||||||||||||||||
| 321 | switch (b->type) { | - | ||||||||||||||||||||||||
| 322 | case never executed: 0:case 0:never executed: case 0: | 0 | ||||||||||||||||||||||||
| 323 | if (!addr_expand(addr_b, b->u.addressPrefix, length, 0x00)
| 0 | ||||||||||||||||||||||||
| 324 | return never executed: -1;return -1;never executed: return -1; | 0 | ||||||||||||||||||||||||
| 325 | prefixlen_b = ((int) ((b->u.addressPrefix)->length * 8 - ((b->u.addressPrefix)->flags & 7))); | - | ||||||||||||||||||||||||
| 326 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 327 | case never executed: 1:case 1:never executed: case 1: | 0 | ||||||||||||||||||||||||
| 328 | if (!addr_expand(addr_b, b->u.addressRange->min, length, 0x00)
| 0 | ||||||||||||||||||||||||
| 329 | return never executed: -1;return -1;never executed: return -1; | 0 | ||||||||||||||||||||||||
| 330 | prefixlen_b = length * 8; | - | ||||||||||||||||||||||||
| 331 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 332 | } | - | ||||||||||||||||||||||||
| 333 | - | |||||||||||||||||||||||||
| 334 | if ((
| 0 | ||||||||||||||||||||||||
| 335 | return never executed: r;return r;never executed: return r; | 0 | ||||||||||||||||||||||||
| 336 | else | - | ||||||||||||||||||||||||
| 337 | return never executed: prefixlen_a - prefixlen_b;return prefixlen_a - prefixlen_b;never executed: return prefixlen_a - prefixlen_b; | 0 | ||||||||||||||||||||||||
| 338 | } | - | ||||||||||||||||||||||||
| 339 | - | |||||||||||||||||||||||||
| 340 | - | |||||||||||||||||||||||||
| 341 | - | |||||||||||||||||||||||||
| 342 | - | |||||||||||||||||||||||||
| 343 | - | |||||||||||||||||||||||||
| 344 | static int v4IPAddressOrRange_cmp(const IPAddressOrRange *const *a, | - | ||||||||||||||||||||||||
| 345 | const IPAddressOrRange *const *b) | - | ||||||||||||||||||||||||
| 346 | { | - | ||||||||||||||||||||||||
| 347 | return never executed: IPAddressOrRange_cmp(*a, *b, 4);return IPAddressOrRange_cmp(*a, *b, 4);never executed: return IPAddressOrRange_cmp(*a, *b, 4); | 0 | ||||||||||||||||||||||||
| 348 | } | - | ||||||||||||||||||||||||
| 349 | - | |||||||||||||||||||||||||
| 350 | - | |||||||||||||||||||||||||
| 351 | - | |||||||||||||||||||||||||
| 352 | - | |||||||||||||||||||||||||
| 353 | - | |||||||||||||||||||||||||
| 354 | static int v6IPAddressOrRange_cmp(const IPAddressOrRange *const *a, | - | ||||||||||||||||||||||||
| 355 | const IPAddressOrRange *const *b) | - | ||||||||||||||||||||||||
| 356 | { | - | ||||||||||||||||||||||||
| 357 | return never executed: IPAddressOrRange_cmp(*a, *b, 16);return IPAddressOrRange_cmp(*a, *b, 16);never executed: return IPAddressOrRange_cmp(*a, *b, 16); | 0 | ||||||||||||||||||||||||
| 358 | } | - | ||||||||||||||||||||||||
| 359 | - | |||||||||||||||||||||||||
| 360 | - | |||||||||||||||||||||||||
| 361 | - | |||||||||||||||||||||||||
| 362 | - | |||||||||||||||||||||||||
| 363 | - | |||||||||||||||||||||||||
| 364 | static int range_should_be_prefix(const unsigned char *min, | - | ||||||||||||||||||||||||
| 365 | const unsigned char *max, const int length) | - | ||||||||||||||||||||||||
| 366 | { | - | ||||||||||||||||||||||||
| 367 | unsigned char mask; | - | ||||||||||||||||||||||||
| 368 | int i, j; | - | ||||||||||||||||||||||||
| 369 | - | |||||||||||||||||||||||||
| 370 | if (memcmp(min, max, length) <= 0
| 0 | ||||||||||||||||||||||||
| 371 | return never executed: -1;return -1;never executed: return -1; | 0 | ||||||||||||||||||||||||
| 372 | for (i = 0; i < length
never executed: ; | 0 | ||||||||||||||||||||||||
| 373 | for (j = length - 1; j >= 0
never executed: ; | 0 | ||||||||||||||||||||||||
| 374 | if (i < j
| 0 | ||||||||||||||||||||||||
| 375 | return never executed: -1;return -1;never executed: return -1; | 0 | ||||||||||||||||||||||||
| 376 | if (i > j
| 0 | ||||||||||||||||||||||||
| 377 | return never executed: i * 8;return i * 8;never executed: return i * 8; | 0 | ||||||||||||||||||||||||
| 378 | mask = min[i] ^ max[i]; | - | ||||||||||||||||||||||||
| 379 | switch (mask) { | - | ||||||||||||||||||||||||
| 380 | case never executed: 0x01:case 0x01:never executed: case 0x01: | 0 | ||||||||||||||||||||||||
| 381 | j = 7; | - | ||||||||||||||||||||||||
| 382 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 383 | case never executed: 0x03:case 0x03:never executed: case 0x03: | 0 | ||||||||||||||||||||||||
| 384 | j = 6; | - | ||||||||||||||||||||||||
| 385 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 386 | case never executed: 0x07:case 0x07:never executed: case 0x07: | 0 | ||||||||||||||||||||||||
| 387 | j = 5; | - | ||||||||||||||||||||||||
| 388 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 389 | case never executed: 0x0F:case 0x0F:never executed: case 0x0F: | 0 | ||||||||||||||||||||||||
| 390 | j = 4; | - | ||||||||||||||||||||||||
| 391 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 392 | case never executed: 0x1F:case 0x1F:never executed: case 0x1F: | 0 | ||||||||||||||||||||||||
| 393 | j = 3; | - | ||||||||||||||||||||||||
| 394 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 395 | case never executed: 0x3F:case 0x3F:never executed: case 0x3F: | 0 | ||||||||||||||||||||||||
| 396 | j = 2; | - | ||||||||||||||||||||||||
| 397 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 398 | case never executed: 0x7F:case 0x7F:never executed: case 0x7F: | 0 | ||||||||||||||||||||||||
| 399 | j = 1; | - | ||||||||||||||||||||||||
| 400 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 401 | default never executed: :default:never executed: default: | 0 | ||||||||||||||||||||||||
| 402 | return never executed: -1;return -1;never executed: return -1; | 0 | ||||||||||||||||||||||||
| 403 | } | - | ||||||||||||||||||||||||
| 404 | if ((
| 0 | ||||||||||||||||||||||||
| 405 | return never executed: -1;return -1;never executed: return -1; | 0 | ||||||||||||||||||||||||
| 406 | else | - | ||||||||||||||||||||||||
| 407 | return never executed: i * 8 + j;return i * 8 + j;never executed: return i * 8 + j; | 0 | ||||||||||||||||||||||||
| 408 | } | - | ||||||||||||||||||||||||
| 409 | - | |||||||||||||||||||||||||
| 410 | - | |||||||||||||||||||||||||
| 411 | - | |||||||||||||||||||||||||
| 412 | - | |||||||||||||||||||||||||
| 413 | static int make_addressPrefix(IPAddressOrRange **result, | - | ||||||||||||||||||||||||
| 414 | unsigned char *addr, const int prefixlen) | - | ||||||||||||||||||||||||
| 415 | { | - | ||||||||||||||||||||||||
| 416 | int bytelen = (prefixlen + 7) / 8, bitlen = prefixlen % 8; | - | ||||||||||||||||||||||||
| 417 | IPAddressOrRange *aor = IPAddressOrRange_new(); | - | ||||||||||||||||||||||||
| 418 | - | |||||||||||||||||||||||||
| 419 | if (aor ==
| 0 | ||||||||||||||||||||||||
| 420 | ((void *)0)
| 0 | ||||||||||||||||||||||||
| 421 | ) | - | ||||||||||||||||||||||||
| 422 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 423 | aor->type = 0; | - | ||||||||||||||||||||||||
| 424 | if (aor->u.addressPrefix ==
| 0 | ||||||||||||||||||||||||
| 425 | ((void *)0)
| 0 | ||||||||||||||||||||||||
| 426 | && | - | ||||||||||||||||||||||||
| 427 | (
| 0 | ||||||||||||||||||||||||
| 428 | ((void *)0)
| 0 | ||||||||||||||||||||||||
| 429 | ) | - | ||||||||||||||||||||||||
| 430 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 431 | if (!ASN1_BIT_STRING_set(aor->u.addressPrefix, addr, bytelen)
| 0 | ||||||||||||||||||||||||
| 432 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 433 | aor->u.addressPrefix->flags &= ~7; | - | ||||||||||||||||||||||||
| 434 | aor->u.addressPrefix->flags |= 0x08; | - | ||||||||||||||||||||||||
| 435 | if (bitlen > 0
| 0 | ||||||||||||||||||||||||
| 436 | aor->u.addressPrefix->data[bytelen - 1] &= ~(0xFF >> bitlen); | - | ||||||||||||||||||||||||
| 437 | aor->u.addressPrefix->flags |= 8 - bitlen; | - | ||||||||||||||||||||||||
| 438 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 439 | - | |||||||||||||||||||||||||
| 440 | *result = aor; | - | ||||||||||||||||||||||||
| 441 | return never executed: 1;return 1;never executed: return 1; | 0 | ||||||||||||||||||||||||
| 442 | - | |||||||||||||||||||||||||
| 443 | err: | - | ||||||||||||||||||||||||
| 444 | IPAddressOrRange_free(aor); | - | ||||||||||||||||||||||||
| 445 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 446 | } | - | ||||||||||||||||||||||||
| 447 | - | |||||||||||||||||||||||||
| 448 | - | |||||||||||||||||||||||||
| 449 | - | |||||||||||||||||||||||||
| 450 | - | |||||||||||||||||||||||||
| 451 | - | |||||||||||||||||||||||||
| 452 | - | |||||||||||||||||||||||||
| 453 | static int make_addressRange(IPAddressOrRange **result, | - | ||||||||||||||||||||||||
| 454 | unsigned char *min, | - | ||||||||||||||||||||||||
| 455 | unsigned char *max, const int length) | - | ||||||||||||||||||||||||
| 456 | { | - | ||||||||||||||||||||||||
| 457 | IPAddressOrRange *aor; | - | ||||||||||||||||||||||||
| 458 | int i, prefixlen; | - | ||||||||||||||||||||||||
| 459 | - | |||||||||||||||||||||||||
| 460 | if ((
| 0 | ||||||||||||||||||||||||
| 461 | return never executed: make_addressPrefix(result, min, prefixlen);return make_addressPrefix(result, min, prefixlen);never executed: return make_addressPrefix(result, min, prefixlen); | 0 | ||||||||||||||||||||||||
| 462 | - | |||||||||||||||||||||||||
| 463 | if ((
| 0 | ||||||||||||||||||||||||
| 464 | ((void *)0)
| 0 | ||||||||||||||||||||||||
| 465 | ) | - | ||||||||||||||||||||||||
| 466 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 467 | aor->type = 1; | - | ||||||||||||||||||||||||
| 468 | if ((
| 0 | ||||||||||||||||||||||||
| 469 | ((void *)0)
| 0 | ||||||||||||||||||||||||
| 470 | ) | - | ||||||||||||||||||||||||
| 471 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 472 | if (aor->u.addressRange->min ==
| 0 | ||||||||||||||||||||||||
| 473 | ((void *)0)
| 0 | ||||||||||||||||||||||||
| 474 | && | - | ||||||||||||||||||||||||
| 475 | (
| 0 | ||||||||||||||||||||||||
| 476 | ((void *)0)
| 0 | ||||||||||||||||||||||||
| 477 | ) | - | ||||||||||||||||||||||||
| 478 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 479 | if (aor->u.addressRange->max ==
| 0 | ||||||||||||||||||||||||
| 480 | ((void *)0)
| 0 | ||||||||||||||||||||||||
| 481 | && | - | ||||||||||||||||||||||||
| 482 | (
| 0 | ||||||||||||||||||||||||
| 483 | ((void *)0)
| 0 | ||||||||||||||||||||||||
| 484 | ) | - | ||||||||||||||||||||||||
| 485 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 486 | - | |||||||||||||||||||||||||
| 487 | for (i = length; i > 0
never executed: ; | 0 | ||||||||||||||||||||||||
| 488 | if (!ASN1_BIT_STRING_set(aor->u.addressRange->min, min, i)
| 0 | ||||||||||||||||||||||||
| 489 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 490 | aor->u.addressRange->min->flags &= ~7; | - | ||||||||||||||||||||||||
| 491 | aor->u.addressRange->min->flags |= 0x08; | - | ||||||||||||||||||||||||
| 492 | if (i > 0
| 0 | ||||||||||||||||||||||||
| 493 | unsigned char b = min[i - 1]; | - | ||||||||||||||||||||||||
| 494 | int j = 1; | - | ||||||||||||||||||||||||
| 495 | while ((
| 0 | ||||||||||||||||||||||||
| 496 | ++ never executed: j;++j;never executed: ++j; | 0 | ||||||||||||||||||||||||
| 497 | aor->u.addressRange->min->flags |= 8 - j; | - | ||||||||||||||||||||||||
| 498 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 499 | - | |||||||||||||||||||||||||
| 500 | for (i = length; i > 0
never executed: ; | 0 | ||||||||||||||||||||||||
| 501 | if (!ASN1_BIT_STRING_set(aor->u.addressRange->max, max, i)
| 0 | ||||||||||||||||||||||||
| 502 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 503 | aor->u.addressRange->max->flags &= ~7; | - | ||||||||||||||||||||||||
| 504 | aor->u.addressRange->max->flags |= 0x08; | - | ||||||||||||||||||||||||
| 505 | if (i > 0
| 0 | ||||||||||||||||||||||||
| 506 | unsigned char b = max[i - 1]; | - | ||||||||||||||||||||||||
| 507 | int j = 1; | - | ||||||||||||||||||||||||
| 508 | while ((
| 0 | ||||||||||||||||||||||||
| 509 | ++ never executed: j;++j;never executed: ++j; | 0 | ||||||||||||||||||||||||
| 510 | aor->u.addressRange->max->flags |= 8 - j; | - | ||||||||||||||||||||||||
| 511 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 512 | - | |||||||||||||||||||||||||
| 513 | *result = aor; | - | ||||||||||||||||||||||||
| 514 | return never executed: 1;return 1;never executed: return 1; | 0 | ||||||||||||||||||||||||
| 515 | - | |||||||||||||||||||||||||
| 516 | err: | - | ||||||||||||||||||||||||
| 517 | IPAddressOrRange_free(aor); | - | ||||||||||||||||||||||||
| 518 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 519 | } | - | ||||||||||||||||||||||||
| 520 | - | |||||||||||||||||||||||||
| 521 | - | |||||||||||||||||||||||||
| 522 | - | |||||||||||||||||||||||||
| 523 | - | |||||||||||||||||||||||||
| 524 | static IPAddressFamily *make_IPAddressFamily(IPAddrBlocks *addr, | - | ||||||||||||||||||||||||
| 525 | const unsigned afi, | - | ||||||||||||||||||||||||
| 526 | const unsigned *safi) | - | ||||||||||||||||||||||||
| 527 | { | - | ||||||||||||||||||||||||
| 528 | IPAddressFamily *f; | - | ||||||||||||||||||||||||
| 529 | unsigned char key[3]; | - | ||||||||||||||||||||||||
| 530 | int keylen; | - | ||||||||||||||||||||||||
| 531 | int i; | - | ||||||||||||||||||||||||
| 532 | - | |||||||||||||||||||||||||
| 533 | key[0] = (afi >> 8) & 0xFF; | - | ||||||||||||||||||||||||
| 534 | key[1] = afi & 0xFF; | - | ||||||||||||||||||||||||
| 535 | if (safi !=
| 0 | ||||||||||||||||||||||||
| 536 | ((void *)0)
| 0 | ||||||||||||||||||||||||
| 537 | ) { | - | ||||||||||||||||||||||||
| 538 | key[2] = *safi & 0xFF; | - | ||||||||||||||||||||||||
| 539 | keylen = 3; | - | ||||||||||||||||||||||||
| 540 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 541 | keylen = 2; | - | ||||||||||||||||||||||||
| 542 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 543 | - | |||||||||||||||||||||||||
| 544 | for (i = 0; i < sk_IPAddressFamily_num(addr)
| 0 | ||||||||||||||||||||||||
| 545 | f = sk_IPAddressFamily_value(addr, i); | - | ||||||||||||||||||||||||
| 546 | if (f->addressFamily->length == keylen
| 0 | ||||||||||||||||||||||||
| 547 | !memcmp(f->addressFamily->data, key, keylen)
| 0 | ||||||||||||||||||||||||
| 548 | return never executed: f;return f;never executed: return f; | 0 | ||||||||||||||||||||||||
| 549 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 550 | - | |||||||||||||||||||||||||
| 551 | if ((
| 0 | ||||||||||||||||||||||||
| 552 | ((void *)0)
| 0 | ||||||||||||||||||||||||
| 553 | ) | - | ||||||||||||||||||||||||
| 554 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 555 | if (f->ipAddressChoice ==
| 0 | ||||||||||||||||||||||||
| 556 | ((void *)0)
| 0 | ||||||||||||||||||||||||
| 557 | && | - | ||||||||||||||||||||||||
| 558 | (
| 0 | ||||||||||||||||||||||||
| 559 | ((void *)0)
| 0 | ||||||||||||||||||||||||
| 560 | ) | - | ||||||||||||||||||||||||
| 561 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 562 | if (f->addressFamily ==
| 0 | ||||||||||||||||||||||||
| 563 | ((void *)0)
| 0 | ||||||||||||||||||||||||
| 564 | && | - | ||||||||||||||||||||||||
| 565 | (
| 0 | ||||||||||||||||||||||||
| 566 | ((void *)0)
| 0 | ||||||||||||||||||||||||
| 567 | ) | - | ||||||||||||||||||||||||
| 568 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 569 | if (!ASN1_OCTET_STRING_set(f->addressFamily, key, keylen)
| 0 | ||||||||||||||||||||||||
| 570 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 571 | if (!sk_IPAddressFamily_push(addr, f)
| 0 | ||||||||||||||||||||||||
| 572 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 573 | - | |||||||||||||||||||||||||
| 574 | return never executed: f;return f;never executed: return f; | 0 | ||||||||||||||||||||||||
| 575 | - | |||||||||||||||||||||||||
| 576 | err: | - | ||||||||||||||||||||||||
| 577 | IPAddressFamily_free(f); | - | ||||||||||||||||||||||||
| 578 | return never executed: return ((void *)0) ;never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||
| 579 | ((void *)0) never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||
| 580 | ; never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||
| 581 | } | - | ||||||||||||||||||||||||
| 582 | - | |||||||||||||||||||||||||
| 583 | - | |||||||||||||||||||||||||
| 584 | - | |||||||||||||||||||||||||
| 585 | - | |||||||||||||||||||||||||
| 586 | int X509v3_addr_add_inherit(IPAddrBlocks *addr, | - | ||||||||||||||||||||||||
| 587 | const unsigned afi, const unsigned *safi) | - | ||||||||||||||||||||||||
| 588 | { | - | ||||||||||||||||||||||||
| 589 | IPAddressFamily *f = make_IPAddressFamily(addr, afi, safi); | - | ||||||||||||||||||||||||
| 590 | if (f ==
| 0 | ||||||||||||||||||||||||
| 591 | ((void *)0)
| 0 | ||||||||||||||||||||||||
| 592 | || | - | ||||||||||||||||||||||||
| 593 | f->ipAddressChoice ==
| 0 | ||||||||||||||||||||||||
| 594 | ((void *)0)
| 0 | ||||||||||||||||||||||||
| 595 | || | - | ||||||||||||||||||||||||
| 596 | (f->ipAddressChoice->type == 1
| 0 | ||||||||||||||||||||||||
| 597 | f->ipAddressChoice->u.addressesOrRanges !=
| 0 | ||||||||||||||||||||||||
| 598 | ((void *)0)
| 0 | ||||||||||||||||||||||||
| 599 | )) | - | ||||||||||||||||||||||||
| 600 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 601 | if (f->ipAddressChoice->type == 0
| 0 | ||||||||||||||||||||||||
| 602 | f->ipAddressChoice->u.inherit !=
| 0 | ||||||||||||||||||||||||
| 603 | ((void *)0)
| 0 | ||||||||||||||||||||||||
| 604 | ) | - | ||||||||||||||||||||||||
| 605 | return never executed: 1;return 1;never executed: return 1; | 0 | ||||||||||||||||||||||||
| 606 | if (f->ipAddressChoice->u.inherit ==
| 0 | ||||||||||||||||||||||||
| 607 | ((void *)0)
| 0 | ||||||||||||||||||||||||
| 608 | && | - | ||||||||||||||||||||||||
| 609 | (
| 0 | ||||||||||||||||||||||||
| 610 | ((void *)0)
| 0 | ||||||||||||||||||||||||
| 611 | ) | - | ||||||||||||||||||||||||
| 612 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 613 | f->ipAddressChoice->type = 0; | - | ||||||||||||||||||||||||
| 614 | return never executed: 1;return 1;never executed: return 1; | 0 | ||||||||||||||||||||||||
| 615 | } | - | ||||||||||||||||||||||||
| 616 | - | |||||||||||||||||||||||||
| 617 | - | |||||||||||||||||||||||||
| 618 | - | |||||||||||||||||||||||||
| 619 | - | |||||||||||||||||||||||||
| 620 | static IPAddressOrRanges *make_prefix_or_range(IPAddrBlocks *addr, | - | ||||||||||||||||||||||||
| 621 | const unsigned afi, | - | ||||||||||||||||||||||||
| 622 | const unsigned *safi) | - | ||||||||||||||||||||||||
| 623 | { | - | ||||||||||||||||||||||||
| 624 | IPAddressFamily *f = make_IPAddressFamily(addr, afi, safi); | - | ||||||||||||||||||||||||
| 625 | IPAddressOrRanges *aors = | - | ||||||||||||||||||||||||
| 626 | ((void *)0) | - | ||||||||||||||||||||||||
| 627 | ; | - | ||||||||||||||||||||||||
| 628 | - | |||||||||||||||||||||||||
| 629 | if (f ==
| 0 | ||||||||||||||||||||||||
| 630 | ((void *)0)
| 0 | ||||||||||||||||||||||||
| 631 | || | - | ||||||||||||||||||||||||
| 632 | f->ipAddressChoice ==
| 0 | ||||||||||||||||||||||||
| 633 | ((void *)0)
| 0 | ||||||||||||||||||||||||
| 634 | || | - | ||||||||||||||||||||||||
| 635 | (f->ipAddressChoice->type == 0
| 0 | ||||||||||||||||||||||||
| 636 | f->ipAddressChoice->u.inherit !=
| 0 | ||||||||||||||||||||||||
| 637 | ((void *)0)
| 0 | ||||||||||||||||||||||||
| 638 | )) | - | ||||||||||||||||||||||||
| 639 | return never executed: return ((void *)0) ;never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||
| 640 | ((void *)0) never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||
| 641 | ; never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||
| 642 | if (f->ipAddressChoice->type == 1
| 0 | ||||||||||||||||||||||||
| 643 | aors = f->ipAddressChoice->u.addressesOrRanges; never executed: aors = f->ipAddressChoice->u.addressesOrRanges; | 0 | ||||||||||||||||||||||||
| 644 | if (aors !=
| 0 | ||||||||||||||||||||||||
| 645 | ((void *)0)
| 0 | ||||||||||||||||||||||||
| 646 | ) | - | ||||||||||||||||||||||||
| 647 | return never executed: aors;return aors;never executed: return aors; | 0 | ||||||||||||||||||||||||
| 648 | if ((
| 0 | ||||||||||||||||||||||||
| 649 | ((void *)0)
| 0 | ||||||||||||||||||||||||
| 650 | ) | - | ||||||||||||||||||||||||
| 651 | return never executed: return ((void *)0) ;never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||
| 652 | ((void *)0) never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||
| 653 | ; never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||
| 654 | switch (afi) { | - | ||||||||||||||||||||||||
| 655 | case never executed: 1:case 1:never executed: case 1: | 0 | ||||||||||||||||||||||||
| 656 | (void)sk_IPAddressOrRange_set_cmp_func(aors, v4IPAddressOrRange_cmp); | - | ||||||||||||||||||||||||
| 657 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 658 | case never executed: 2:case 2:never executed: case 2: | 0 | ||||||||||||||||||||||||
| 659 | (void)sk_IPAddressOrRange_set_cmp_func(aors, v6IPAddressOrRange_cmp); | - | ||||||||||||||||||||||||
| 660 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 661 | } | - | ||||||||||||||||||||||||
| 662 | f->ipAddressChoice->type = 1; | - | ||||||||||||||||||||||||
| 663 | f->ipAddressChoice->u.addressesOrRanges = aors; | - | ||||||||||||||||||||||||
| 664 | return never executed: aors;return aors;never executed: return aors; | 0 | ||||||||||||||||||||||||
| 665 | } | - | ||||||||||||||||||||||||
| 666 | - | |||||||||||||||||||||||||
| 667 | - | |||||||||||||||||||||||||
| 668 | - | |||||||||||||||||||||||||
| 669 | - | |||||||||||||||||||||||||
| 670 | int X509v3_addr_add_prefix(IPAddrBlocks *addr, | - | ||||||||||||||||||||||||
| 671 | const unsigned afi, | - | ||||||||||||||||||||||||
| 672 | const unsigned *safi, | - | ||||||||||||||||||||||||
| 673 | unsigned char *a, const int prefixlen) | - | ||||||||||||||||||||||||
| 674 | { | - | ||||||||||||||||||||||||
| 675 | IPAddressOrRanges *aors = make_prefix_or_range(addr, afi, safi); | - | ||||||||||||||||||||||||
| 676 | IPAddressOrRange *aor; | - | ||||||||||||||||||||||||
| 677 | if (aors ==
| 0 | ||||||||||||||||||||||||
| 678 | ((void *)0)
| 0 | ||||||||||||||||||||||||
| 679 | || !make_addressPrefix(&aor, a, prefixlen)
| 0 | ||||||||||||||||||||||||
| 680 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 681 | if (sk_IPAddressOrRange_push(aors, aor)
| 0 | ||||||||||||||||||||||||
| 682 | return never executed: 1;return 1;never executed: return 1; | 0 | ||||||||||||||||||||||||
| 683 | IPAddressOrRange_free(aor); | - | ||||||||||||||||||||||||
| 684 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 685 | } | - | ||||||||||||||||||||||||
| 686 | - | |||||||||||||||||||||||||
| 687 | - | |||||||||||||||||||||||||
| 688 | - | |||||||||||||||||||||||||
| 689 | - | |||||||||||||||||||||||||
| 690 | int X509v3_addr_add_range(IPAddrBlocks *addr, | - | ||||||||||||||||||||||||
| 691 | const unsigned afi, | - | ||||||||||||||||||||||||
| 692 | const unsigned *safi, | - | ||||||||||||||||||||||||
| 693 | unsigned char *min, unsigned char *max) | - | ||||||||||||||||||||||||
| 694 | { | - | ||||||||||||||||||||||||
| 695 | IPAddressOrRanges *aors = make_prefix_or_range(addr, afi, safi); | - | ||||||||||||||||||||||||
| 696 | IPAddressOrRange *aor; | - | ||||||||||||||||||||||||
| 697 | int length = length_from_afi(afi); | - | ||||||||||||||||||||||||
| 698 | if (aors ==
| 0 | ||||||||||||||||||||||||
| 699 | ((void *)0)
| 0 | ||||||||||||||||||||||||
| 700 | ) | - | ||||||||||||||||||||||||
| 701 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 702 | if (!make_addressRange(&aor, min, max, length)
| 0 | ||||||||||||||||||||||||
| 703 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 704 | if (sk_IPAddressOrRange_push(aors, aor)
| 0 | ||||||||||||||||||||||||
| 705 | return never executed: 1;return 1;never executed: return 1; | 0 | ||||||||||||||||||||||||
| 706 | IPAddressOrRange_free(aor); | - | ||||||||||||||||||||||||
| 707 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 708 | } | - | ||||||||||||||||||||||||
| 709 | - | |||||||||||||||||||||||||
| 710 | - | |||||||||||||||||||||||||
| 711 | - | |||||||||||||||||||||||||
| 712 | - | |||||||||||||||||||||||||
| 713 | static int extract_min_max(IPAddressOrRange *aor, | - | ||||||||||||||||||||||||
| 714 | unsigned char *min, unsigned char *max, int length) | - | ||||||||||||||||||||||||
| 715 | { | - | ||||||||||||||||||||||||
| 716 | if (aor ==
| 0 | ||||||||||||||||||||||||
| 717 | ((void *)0)
| 0 | ||||||||||||||||||||||||
| 718 | || min ==
| 0 | ||||||||||||||||||||||||
| 719 | ((void *)0)
| 0 | ||||||||||||||||||||||||
| 720 | || max ==
| 0 | ||||||||||||||||||||||||
| 721 | ((void *)0)
| 0 | ||||||||||||||||||||||||
| 722 | ) | - | ||||||||||||||||||||||||
| 723 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 724 | switch (aor->type) { | - | ||||||||||||||||||||||||
| 725 | case never executed: 0:case 0:never executed: case 0: | 0 | ||||||||||||||||||||||||
| 726 | return never executed: (addr_expand(min, aor->u.addressPrefix, length, 0x00)return (addr_expand(min, aor->u.addressPrefix, length, 0x00) && addr_expand(max, aor->u.addressPrefix, length, 0xFF));
never executed: return (addr_expand(min, aor->u.addressPrefix, length, 0x00) && addr_expand(max, aor->u.addressPrefix, length, 0xFF)); | 0 | ||||||||||||||||||||||||
| 727 | addr_expand(max, aor->u.addressPrefix, length, 0xFF)
never executed: return (addr_expand(min, aor->u.addressPrefix, length, 0x00) && addr_expand(max, aor->u.addressPrefix, length, 0xFF)); | 0 | ||||||||||||||||||||||||
| 728 | case never executed: 1:case 1:never executed: case 1: | 0 | ||||||||||||||||||||||||
| 729 | return never executed: (addr_expand(min, aor->u.addressRange->min, length, 0x00)return (addr_expand(min, aor->u.addressRange->min, length, 0x00) && addr_expand(max, aor->u.addressRange->max, length, 0xFF));
never executed: return (addr_expand(min, aor->u.addressRange->min, length, 0x00) && addr_expand(max, aor->u.addressRange->max, length, 0xFF)); | 0 | ||||||||||||||||||||||||
| 730 | addr_expand(max, aor->u.addressRange->max, length, 0xFF)
never executed: return (addr_expand(min, aor->u.addressRange->min, length, 0x00) && addr_expand(max, aor->u.addressRange->max, length, 0xFF)); | 0 | ||||||||||||||||||||||||
| 731 | } | - | ||||||||||||||||||||||||
| 732 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 733 | } | - | ||||||||||||||||||||||||
| 734 | - | |||||||||||||||||||||||||
| 735 | - | |||||||||||||||||||||||||
| 736 | - | |||||||||||||||||||||||||
| 737 | - | |||||||||||||||||||||||||
| 738 | int X509v3_addr_get_range(IPAddressOrRange *aor, | - | ||||||||||||||||||||||||
| 739 | const unsigned afi, | - | ||||||||||||||||||||||||
| 740 | unsigned char *min, | - | ||||||||||||||||||||||||
| 741 | unsigned char *max, const int length) | - | ||||||||||||||||||||||||
| 742 | { | - | ||||||||||||||||||||||||
| 743 | int afi_length = length_from_afi(afi); | - | ||||||||||||||||||||||||
| 744 | if (aor ==
| 0 | ||||||||||||||||||||||||
| 745 | ((void *)0)
| 0 | ||||||||||||||||||||||||
| 746 | || min ==
| 0 | ||||||||||||||||||||||||
| 747 | ((void *)0)
| 0 | ||||||||||||||||||||||||
| 748 | || max ==
| 0 | ||||||||||||||||||||||||
| 749 | ((void *)0)
| 0 | ||||||||||||||||||||||||
| 750 | || | - | ||||||||||||||||||||||||
| 751 | afi_length == 0
| 0 | ||||||||||||||||||||||||
| 752 | (aor->type != 0
| 0 | ||||||||||||||||||||||||
| 753 | aor->type != 1
| 0 | ||||||||||||||||||||||||
| 754 | !extract_min_max(aor, min, max, afi_length)
| 0 | ||||||||||||||||||||||||
| 755 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 756 | - | |||||||||||||||||||||||||
| 757 | return never executed: afi_length;return afi_length;never executed: return afi_length; | 0 | ||||||||||||||||||||||||
| 758 | } | - | ||||||||||||||||||||||||
| 759 | static int IPAddressFamily_cmp(const IPAddressFamily *const *a_, | - | ||||||||||||||||||||||||
| 760 | const IPAddressFamily *const *b_) | - | ||||||||||||||||||||||||
| 761 | { | - | ||||||||||||||||||||||||
| 762 | const ASN1_OCTET_STRING *a = (*a_)->addressFamily; | - | ||||||||||||||||||||||||
| 763 | const ASN1_OCTET_STRING *b = (*b_)->addressFamily; | - | ||||||||||||||||||||||||
| 764 | int len = ((
| 0 | ||||||||||||||||||||||||
| 765 | int cmp = memcmp(a->data, b->data, len); | - | ||||||||||||||||||||||||
| 766 | return never executed: cmpreturn cmp ? cmp : a->length - b->length;
never executed: return cmp ? cmp : a->length - b->length; | 0 | ||||||||||||||||||||||||
| 767 | } | - | ||||||||||||||||||||||||
| 768 | - | |||||||||||||||||||||||||
| 769 | - | |||||||||||||||||||||||||
| 770 | - | |||||||||||||||||||||||||
| 771 | - | |||||||||||||||||||||||||
| 772 | int X509v3_addr_is_canonical(IPAddrBlocks *addr) | - | ||||||||||||||||||||||||
| 773 | { | - | ||||||||||||||||||||||||
| 774 | unsigned char a_min[16], a_max[16]; | - | ||||||||||||||||||||||||
| 775 | unsigned char b_min[16], b_max[16]; | - | ||||||||||||||||||||||||
| 776 | IPAddressOrRanges *aors; | - | ||||||||||||||||||||||||
| 777 | int i, j, k; | - | ||||||||||||||||||||||||
| 778 | - | |||||||||||||||||||||||||
| 779 | - | |||||||||||||||||||||||||
| 780 | - | |||||||||||||||||||||||||
| 781 | - | |||||||||||||||||||||||||
| 782 | if (addr ==
| 0 | ||||||||||||||||||||||||
| 783 | ((void *)0)
| 0 | ||||||||||||||||||||||||
| 784 | ) | - | ||||||||||||||||||||||||
| 785 | return never executed: 1;return 1;never executed: return 1; | 0 | ||||||||||||||||||||||||
| 786 | - | |||||||||||||||||||||||||
| 787 | - | |||||||||||||||||||||||||
| 788 | - | |||||||||||||||||||||||||
| 789 | - | |||||||||||||||||||||||||
| 790 | for (i = 0; i < sk_IPAddressFamily_num(addr) - 1
| 0 | ||||||||||||||||||||||||
| 791 | const IPAddressFamily *a = sk_IPAddressFamily_value(addr, i); | - | ||||||||||||||||||||||||
| 792 | const IPAddressFamily *b = sk_IPAddressFamily_value(addr, i + 1); | - | ||||||||||||||||||||||||
| 793 | if (IPAddressFamily_cmp(&a, &b) >= 0
| 0 | ||||||||||||||||||||||||
| 794 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 795 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 796 | - | |||||||||||||||||||||||||
| 797 | - | |||||||||||||||||||||||||
| 798 | - | |||||||||||||||||||||||||
| 799 | - | |||||||||||||||||||||||||
| 800 | for (i = 0; i < sk_IPAddressFamily_num(addr)
| 0 | ||||||||||||||||||||||||
| 801 | IPAddressFamily *f = sk_IPAddressFamily_value(addr, i); | - | ||||||||||||||||||||||||
| 802 | int length = length_from_afi(X509v3_addr_get_afi(f)); | - | ||||||||||||||||||||||||
| 803 | - | |||||||||||||||||||||||||
| 804 | - | |||||||||||||||||||||||||
| 805 | - | |||||||||||||||||||||||||
| 806 | - | |||||||||||||||||||||||||
| 807 | - | |||||||||||||||||||||||||
| 808 | if (f ==
| 0 | ||||||||||||||||||||||||
| 809 | ((void *)0)
| 0 | ||||||||||||||||||||||||
| 810 | || f->ipAddressChoice ==
| 0 | ||||||||||||||||||||||||
| 811 | ((void *)0)
| 0 | ||||||||||||||||||||||||
| 812 | ) | - | ||||||||||||||||||||||||
| 813 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 814 | switch (f->ipAddressChoice->type) { | - | ||||||||||||||||||||||||
| 815 | case never executed: 0:case 0:never executed: case 0: | 0 | ||||||||||||||||||||||||
| 816 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 817 | case never executed: 1:case 1:never executed: case 1: | 0 | ||||||||||||||||||||||||
| 818 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 819 | default never executed: :default:never executed: default: | 0 | ||||||||||||||||||||||||
| 820 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 821 | } | - | ||||||||||||||||||||||||
| 822 | - | |||||||||||||||||||||||||
| 823 | - | |||||||||||||||||||||||||
| 824 | - | |||||||||||||||||||||||||
| 825 | - | |||||||||||||||||||||||||
| 826 | aors = f->ipAddressChoice->u.addressesOrRanges; | - | ||||||||||||||||||||||||
| 827 | if (sk_IPAddressOrRange_num(aors) == 0
| 0 | ||||||||||||||||||||||||
| 828 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 829 | for (j = 0; j < sk_IPAddressOrRange_num(aors) - 1
| 0 | ||||||||||||||||||||||||
| 830 | IPAddressOrRange *a = sk_IPAddressOrRange_value(aors, j); | - | ||||||||||||||||||||||||
| 831 | IPAddressOrRange *b = sk_IPAddressOrRange_value(aors, j + 1); | - | ||||||||||||||||||||||||
| 832 | - | |||||||||||||||||||||||||
| 833 | if (!extract_min_max(a, a_min, a_max, length)
| 0 | ||||||||||||||||||||||||
| 834 | !extract_min_max(b, b_min, b_max, length)
| 0 | ||||||||||||||||||||||||
| 835 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 836 | - | |||||||||||||||||||||||||
| 837 | - | |||||||||||||||||||||||||
| 838 | - | |||||||||||||||||||||||||
| 839 | - | |||||||||||||||||||||||||
| 840 | if (memcmp(a_min, b_min, length) >= 0
| 0 | ||||||||||||||||||||||||
| 841 | memcmp(a_min, a_max, length) > 0
| 0 | ||||||||||||||||||||||||
| 842 | memcmp(b_min, b_max, length) > 0
| 0 | ||||||||||||||||||||||||
| 843 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 844 | - | |||||||||||||||||||||||||
| 845 | - | |||||||||||||||||||||||||
| 846 | - | |||||||||||||||||||||||||
| 847 | - | |||||||||||||||||||||||||
| 848 | - | |||||||||||||||||||||||||
| 849 | for (k = length - 1; k >= 0
never executed: ; | 0 | ||||||||||||||||||||||||
| 850 | if (memcmp(a_max, b_min, length) >= 0
| 0 | ||||||||||||||||||||||||
| 851 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 852 | - | |||||||||||||||||||||||||
| 853 | - | |||||||||||||||||||||||||
| 854 | - | |||||||||||||||||||||||||
| 855 | - | |||||||||||||||||||||||||
| 856 | if (a->type == 1
| 0 | ||||||||||||||||||||||||
| 857 | range_should_be_prefix(a_min, a_max, length) >= 0
| 0 | ||||||||||||||||||||||||
| 858 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 859 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 860 | - | |||||||||||||||||||||||||
| 861 | - | |||||||||||||||||||||||||
| 862 | - | |||||||||||||||||||||||||
| 863 | - | |||||||||||||||||||||||||
| 864 | - | |||||||||||||||||||||||||
| 865 | j = sk_IPAddressOrRange_num(aors) - 1; | - | ||||||||||||||||||||||||
| 866 | { | - | ||||||||||||||||||||||||
| 867 | IPAddressOrRange *a = sk_IPAddressOrRange_value(aors, j); | - | ||||||||||||||||||||||||
| 868 | if (a !=
| 0 | ||||||||||||||||||||||||
| 869 | ((void *)0)
| 0 | ||||||||||||||||||||||||
| 870 | && a->type == 1
| 0 | ||||||||||||||||||||||||
| 871 | if (!extract_min_max(a, a_min, a_max, length)
| 0 | ||||||||||||||||||||||||
| 872 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 873 | if (memcmp(a_min, a_max, length) > 0
| 0 | ||||||||||||||||||||||||
| 874 | range_should_be_prefix(a_min, a_max, length) >= 0
| 0 | ||||||||||||||||||||||||
| 875 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 876 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 877 | } | - | ||||||||||||||||||||||||
| 878 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 879 | - | |||||||||||||||||||||||||
| 880 | - | |||||||||||||||||||||||||
| 881 | - | |||||||||||||||||||||||||
| 882 | - | |||||||||||||||||||||||||
| 883 | return never executed: 1;return 1;never executed: return 1; | 0 | ||||||||||||||||||||||||
| 884 | } | - | ||||||||||||||||||||||||
| 885 | - | |||||||||||||||||||||||||
| 886 | - | |||||||||||||||||||||||||
| 887 | - | |||||||||||||||||||||||||
| 888 | - | |||||||||||||||||||||||||
| 889 | static int IPAddressOrRanges_canonize(IPAddressOrRanges *aors, | - | ||||||||||||||||||||||||
| 890 | const unsigned afi) | - | ||||||||||||||||||||||||
| 891 | { | - | ||||||||||||||||||||||||
| 892 | int i, j, length = length_from_afi(afi); | - | ||||||||||||||||||||||||
| 893 | - | |||||||||||||||||||||||||
| 894 | - | |||||||||||||||||||||||||
| 895 | - | |||||||||||||||||||||||||
| 896 | - | |||||||||||||||||||||||||
| 897 | sk_IPAddressOrRange_sort(aors); | - | ||||||||||||||||||||||||
| 898 | - | |||||||||||||||||||||||||
| 899 | - | |||||||||||||||||||||||||
| 900 | - | |||||||||||||||||||||||||
| 901 | - | |||||||||||||||||||||||||
| 902 | for (i = 0; i < sk_IPAddressOrRange_num(aors) - 1
| 0 | ||||||||||||||||||||||||
| 903 | IPAddressOrRange *a = sk_IPAddressOrRange_value(aors, i); | - | ||||||||||||||||||||||||
| 904 | IPAddressOrRange *b = sk_IPAddressOrRange_value(aors, i + 1); | - | ||||||||||||||||||||||||
| 905 | unsigned char a_min[16], a_max[16]; | - | ||||||||||||||||||||||||
| 906 | unsigned char b_min[16], b_max[16]; | - | ||||||||||||||||||||||||
| 907 | - | |||||||||||||||||||||||||
| 908 | if (!extract_min_max(a, a_min, a_max, length)
| 0 | ||||||||||||||||||||||||
| 909 | !extract_min_max(b, b_min, b_max, length)
| 0 | ||||||||||||||||||||||||
| 910 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 911 | - | |||||||||||||||||||||||||
| 912 | - | |||||||||||||||||||||||||
| 913 | - | |||||||||||||||||||||||||
| 914 | - | |||||||||||||||||||||||||
| 915 | if (memcmp(a_min, a_max, length) > 0
| 0 | ||||||||||||||||||||||||
| 916 | memcmp(b_min, b_max, length) > 0
| 0 | ||||||||||||||||||||||||
| 917 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 918 | - | |||||||||||||||||||||||||
| 919 | - | |||||||||||||||||||||||||
| 920 | - | |||||||||||||||||||||||||
| 921 | - | |||||||||||||||||||||||||
| 922 | if (memcmp(a_max, b_min, length) >= 0
| 0 | ||||||||||||||||||||||||
| 923 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 924 | - | |||||||||||||||||||||||||
| 925 | - | |||||||||||||||||||||||||
| 926 | - | |||||||||||||||||||||||||
| 927 | - | |||||||||||||||||||||||||
| 928 | - | |||||||||||||||||||||||||
| 929 | for (j = length - 1; j >= 0
never executed: ; | 0 | ||||||||||||||||||||||||
| 930 | if (memcmp(a_max, b_min, length) == 0
| 0 | ||||||||||||||||||||||||
| 931 | IPAddressOrRange *merged; | - | ||||||||||||||||||||||||
| 932 | if (!make_addressRange(&merged, a_min, b_max, length)
| 0 | ||||||||||||||||||||||||
| 933 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 934 | (void)sk_IPAddressOrRange_set(aors, i, merged); | - | ||||||||||||||||||||||||
| 935 | (void)sk_IPAddressOrRange_delete(aors, i + 1); | - | ||||||||||||||||||||||||
| 936 | IPAddressOrRange_free(a); | - | ||||||||||||||||||||||||
| 937 | IPAddressOrRange_free(b); | - | ||||||||||||||||||||||||
| 938 | --i; | - | ||||||||||||||||||||||||
| 939 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 940 | } | - | ||||||||||||||||||||||||
| 941 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 942 | - | |||||||||||||||||||||||||
| 943 | - | |||||||||||||||||||||||||
| 944 | - | |||||||||||||||||||||||||
| 945 | - | |||||||||||||||||||||||||
| 946 | j = sk_IPAddressOrRange_num(aors) - 1; | - | ||||||||||||||||||||||||
| 947 | { | - | ||||||||||||||||||||||||
| 948 | IPAddressOrRange *a = sk_IPAddressOrRange_value(aors, j); | - | ||||||||||||||||||||||||
| 949 | if (a !=
| 0 | ||||||||||||||||||||||||
| 950 | ((void *)0)
| 0 | ||||||||||||||||||||||||
| 951 | && a->type == 1
| 0 | ||||||||||||||||||||||||
| 952 | unsigned char a_min[16], a_max[16]; | - | ||||||||||||||||||||||||
| 953 | if (!extract_min_max(a, a_min, a_max, length)
| 0 | ||||||||||||||||||||||||
| 954 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 955 | if (memcmp(a_min, a_max, length) > 0
| 0 | ||||||||||||||||||||||||
| 956 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 957 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 958 | } | - | ||||||||||||||||||||||||
| 959 | - | |||||||||||||||||||||||||
| 960 | return never executed: 1;return 1;never executed: return 1; | 0 | ||||||||||||||||||||||||
| 961 | } | - | ||||||||||||||||||||||||
| 962 | - | |||||||||||||||||||||||||
| 963 | - | |||||||||||||||||||||||||
| 964 | - | |||||||||||||||||||||||||
| 965 | - | |||||||||||||||||||||||||
| 966 | int X509v3_addr_canonize(IPAddrBlocks *addr) | - | ||||||||||||||||||||||||
| 967 | { | - | ||||||||||||||||||||||||
| 968 | int i; | - | ||||||||||||||||||||||||
| 969 | for (i = 0; i < sk_IPAddressFamily_num(addr)
| 0 | ||||||||||||||||||||||||
| 970 | IPAddressFamily *f = sk_IPAddressFamily_value(addr, i); | - | ||||||||||||||||||||||||
| 971 | if (f->ipAddressChoice->type == 1
| 0 | ||||||||||||||||||||||||
| 972 | !IPAddressOrRanges_canonize(f->ipAddressChoice->
| 0 | ||||||||||||||||||||||||
| 973 | u.addressesOrRanges,
| 0 | ||||||||||||||||||||||||
| 974 | X509v3_addr_get_afi(f))
| 0 | ||||||||||||||||||||||||
| 975 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 976 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 977 | (void)sk_IPAddressFamily_set_cmp_func(addr, IPAddressFamily_cmp); | - | ||||||||||||||||||||||||
| 978 | sk_IPAddressFamily_sort(addr); | - | ||||||||||||||||||||||||
| 979 | if (!((X509v3_addr_is_canonical(addr)) != 0)
| 0 | ||||||||||||||||||||||||
| 980 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 981 | return never executed: 1;return 1;never executed: return 1; | 0 | ||||||||||||||||||||||||
| 982 | } | - | ||||||||||||||||||||||||
| 983 | - | |||||||||||||||||||||||||
| 984 | - | |||||||||||||||||||||||||
| 985 | - | |||||||||||||||||||||||||
| 986 | - | |||||||||||||||||||||||||
| 987 | static void *v2i_IPAddrBlocks(const struct v3_ext_method *method, | - | ||||||||||||||||||||||||
| 988 | struct v3_ext_ctx *ctx, | - | ||||||||||||||||||||||||
| 989 | struct stack_st_CONF_VALUE *values) | - | ||||||||||||||||||||||||
| 990 | { | - | ||||||||||||||||||||||||
| 991 | static const char v4addr_chars[] = "0123456789."; | - | ||||||||||||||||||||||||
| 992 | static const char v6addr_chars[] = "0123456789.:abcdefABCDEF"; | - | ||||||||||||||||||||||||
| 993 | IPAddrBlocks *addr = | - | ||||||||||||||||||||||||
| 994 | ((void *)0) | - | ||||||||||||||||||||||||
| 995 | ; | - | ||||||||||||||||||||||||
| 996 | char *s = | - | ||||||||||||||||||||||||
| 997 | ((void *)0) | - | ||||||||||||||||||||||||
| 998 | , *t; | - | ||||||||||||||||||||||||
| 999 | int i; | - | ||||||||||||||||||||||||
| 1000 | - | |||||||||||||||||||||||||
| 1001 | if ((
| 0 | ||||||||||||||||||||||||
| 1002 | ((void *)0)
| 0 | ||||||||||||||||||||||||
| 1003 | ) { | - | ||||||||||||||||||||||||
| 1004 | ERR_put_error(34,(159),((1|64)),__FILE__,898); | - | ||||||||||||||||||||||||
| 1005 | return never executed: return ((void *)0) ;never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||
| 1006 | ((void *)0) never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||
| 1007 | ; never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||
| 1008 | } | - | ||||||||||||||||||||||||
| 1009 | - | |||||||||||||||||||||||||
| 1010 | for (i = 0; i < sk_CONF_VALUE_num(values)
| 0 | ||||||||||||||||||||||||
| 1011 | CONF_VALUE *val = sk_CONF_VALUE_value(values, i); | - | ||||||||||||||||||||||||
| 1012 | unsigned char min[16], max[16]; | - | ||||||||||||||||||||||||
| 1013 | unsigned afi, *safi = | - | ||||||||||||||||||||||||
| 1014 | ((void *)0) | - | ||||||||||||||||||||||||
| 1015 | , safi_; | - | ||||||||||||||||||||||||
| 1016 | const char *addr_chars = | - | ||||||||||||||||||||||||
| 1017 | ((void *)0) | - | ||||||||||||||||||||||||
| 1018 | ; | - | ||||||||||||||||||||||||
| 1019 | int prefixlen, i1, i2, delim, length; | - | ||||||||||||||||||||||||
| 1020 | - | |||||||||||||||||||||||||
| 1021 | if (!name_cmp(val->name, "IPv4")
| 0 | ||||||||||||||||||||||||
| 1022 | afi = 1; | - | ||||||||||||||||||||||||
| 1023 | } never executed: else if (!name_cmp(val->name, "IPv6")end of block
| 0 | ||||||||||||||||||||||||
| 1024 | afi = 2; | - | ||||||||||||||||||||||||
| 1025 | } never executed: else if (!name_cmp(val->name, "IPv4-SAFI")end of block
| 0 | ||||||||||||||||||||||||
| 1026 | afi = 1; | - | ||||||||||||||||||||||||
| 1027 | safi = &safi_; | - | ||||||||||||||||||||||||
| 1028 | } never executed: else if (!name_cmp(val->name, "IPv6-SAFI")end of block
| 0 | ||||||||||||||||||||||||
| 1029 | afi = 2; | - | ||||||||||||||||||||||||
| 1030 | safi = &safi_; | - | ||||||||||||||||||||||||
| 1031 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 1032 | ERR_put_error(34,(159),(115),__FILE__,921) | - | ||||||||||||||||||||||||
| 1033 | ; | - | ||||||||||||||||||||||||
| 1034 | ERR_add_error_data(6, "section:", (val)->section, ",name:", (val)->name, ",value:", (val)->value); | - | ||||||||||||||||||||||||
| 1035 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 1036 | } | - | ||||||||||||||||||||||||
| 1037 | - | |||||||||||||||||||||||||
| 1038 | switch (afi) { | - | ||||||||||||||||||||||||
| 1039 | case never executed: 1:case 1:never executed: case 1: | 0 | ||||||||||||||||||||||||
| 1040 | addr_chars = v4addr_chars; | - | ||||||||||||||||||||||||
| 1041 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 1042 | case never executed: 2:case 2:never executed: case 2: | 0 | ||||||||||||||||||||||||
| 1043 | addr_chars = v6addr_chars; | - | ||||||||||||||||||||||||
| 1044 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 1045 | } | - | ||||||||||||||||||||||||
| 1046 | - | |||||||||||||||||||||||||
| 1047 | length = length_from_afi(afi); | - | ||||||||||||||||||||||||
| 1048 | - | |||||||||||||||||||||||||
| 1049 | - | |||||||||||||||||||||||||
| 1050 | - | |||||||||||||||||||||||||
| 1051 | - | |||||||||||||||||||||||||
| 1052 | - | |||||||||||||||||||||||||
| 1053 | if (safi !=
| 0 | ||||||||||||||||||||||||
| 1054 | ((void *)0)
| 0 | ||||||||||||||||||||||||
| 1055 | ) { | - | ||||||||||||||||||||||||
| 1056 | *safi = strtoul(val->value, &t, 0); | - | ||||||||||||||||||||||||
| 1057 | t += | - | ||||||||||||||||||||||||
| 1058 | __builtin_strspn ( | - | ||||||||||||||||||||||||
| 1059 | t | - | ||||||||||||||||||||||||
| 1060 | , | - | ||||||||||||||||||||||||
| 1061 | " \t" | - | ||||||||||||||||||||||||
| 1062 | ) | - | ||||||||||||||||||||||||
| 1063 | ; | - | ||||||||||||||||||||||||
| 1064 | if (*
| 0 | ||||||||||||||||||||||||
| 1065 | ERR_put_error(34,(159),(164),__FILE__,945); | - | ||||||||||||||||||||||||
| 1066 | ERR_add_error_data(6, "section:", (val)->section, ",name:", (val)->name, ",value:", (val)->value); | - | ||||||||||||||||||||||||
| 1067 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 1068 | } | - | ||||||||||||||||||||||||
| 1069 | t += | - | ||||||||||||||||||||||||
| 1070 | __builtin_strspn ( | - | ||||||||||||||||||||||||
| 1071 | t | - | ||||||||||||||||||||||||
| 1072 | , | - | ||||||||||||||||||||||||
| 1073 | " \t" | - | ||||||||||||||||||||||||
| 1074 | ) | - | ||||||||||||||||||||||||
| 1075 | ; | - | ||||||||||||||||||||||||
| 1076 | s = CRYPTO_strdup(t, __FILE__, 950); | - | ||||||||||||||||||||||||
| 1077 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 1078 | s = CRYPTO_strdup(val->value, __FILE__, 952); | - | ||||||||||||||||||||||||
| 1079 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1080 | if (s ==
| 0 | ||||||||||||||||||||||||
| 1081 | ((void *)0)
| 0 | ||||||||||||||||||||||||
| 1082 | ) { | - | ||||||||||||||||||||||||
| 1083 | ERR_put_error(34,(159),((1|64)),__FILE__,955); | - | ||||||||||||||||||||||||
| 1084 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 1085 | } | - | ||||||||||||||||||||||||
| 1086 | - | |||||||||||||||||||||||||
| 1087 | - | |||||||||||||||||||||||||
| 1088 | - | |||||||||||||||||||||||||
| 1089 | - | |||||||||||||||||||||||||
| 1090 | - | |||||||||||||||||||||||||
| 1091 | if ( | - | ||||||||||||||||||||||||
| 1092 | __extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (
| 0 | ||||||||||||||||||||||||
| 1093 | s
| 0 | ||||||||||||||||||||||||
| 1094 | ) && __builtin_constant_p (
| 0 | ||||||||||||||||||||||||
| 1095 | "inherit"
| 0 | ||||||||||||||||||||||||
| 1096 | ) && (__s1_len = __builtin_strlen (
| 0 | ||||||||||||||||||||||||
| 1097 | s
| 0 | ||||||||||||||||||||||||
| 1098 | ), __s2_len = __builtin_strlen (
| 0 | ||||||||||||||||||||||||
| 1099 | "inherit"
| 0 | ||||||||||||||||||||||||
| 1100 | ), (!((size_t)(const void *)((
| 0 | ||||||||||||||||||||||||
| 1101 | s
| 0 | ||||||||||||||||||||||||
| 1102 | ) + 1) - (size_t)(const void *)(
| 0 | ||||||||||||||||||||||||
| 1103 | s
| 0 | ||||||||||||||||||||||||
| 1104 | ) == 1) || __s1_len >= 4) && (!((size_t)(const void *)((
| 0 | ||||||||||||||||||||||||
| 1105 | "inherit"
| 0 | ||||||||||||||||||||||||
| 1106 | ) + 1) - (size_t)(const void *)(
| 0 | ||||||||||||||||||||||||
| 1107 | "inherit"
| 0 | ||||||||||||||||||||||||
| 1108 | ) == 1) || __s2_len >= 4)) ? __builtin_strcmp (
| 0 | ||||||||||||||||||||||||
| 1109 | s
| 0 | ||||||||||||||||||||||||
| 1110 | ,
| 0 | ||||||||||||||||||||||||
| 1111 | "inherit"
| 0 | ||||||||||||||||||||||||
| 1112 | ) : (__builtin_constant_p (
| 0 | ||||||||||||||||||||||||
| 1113 | s
| 0 | ||||||||||||||||||||||||
| 1114 | ) && ((size_t)(const void *)((
| 0 | ||||||||||||||||||||||||
| 1115 | s
| 0 | ||||||||||||||||||||||||
| 1116 | ) + 1) - (size_t)(const void *)(
| 0 | ||||||||||||||||||||||||
| 1117 | s
| 0 | ||||||||||||||||||||||||
| 1118 | ) == 1) && (__s1_len = __builtin_strlen (
| 0 | ||||||||||||||||||||||||
| 1119 | s
| 0 | ||||||||||||||||||||||||
| 1120 | ), __s1_len < 4) ? (__builtin_constant_p (
| 0 | ||||||||||||||||||||||||
| 1121 | "inherit"
| 0 | ||||||||||||||||||||||||
| 1122 | ) && ((size_t)(const void *)((
| 0 | ||||||||||||||||||||||||
| 1123 | "inherit"
| 0 | ||||||||||||||||||||||||
| 1124 | ) + 1) - (size_t)(const void *)(
| 0 | ||||||||||||||||||||||||
| 1125 | "inherit"
| 0 | ||||||||||||||||||||||||
| 1126 | ) == 1) ? __builtin_strcmp (
| 0 | ||||||||||||||||||||||||
| 1127 | s
| 0 | ||||||||||||||||||||||||
| 1128 | ,
| 0 | ||||||||||||||||||||||||
| 1129 | "inherit"
| 0 | ||||||||||||||||||||||||
| 1130 | ) : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (
| 0 | ||||||||||||||||||||||||
| 1131 | "inherit"
| 0 | ||||||||||||||||||||||||
| 1132 | ); int __result = (((const unsigned char *) (const char *) (
| 0 | ||||||||||||||||||||||||
| 1133 | s
| 0 | ||||||||||||||||||||||||
| 1134 | ))[0] - __s2[0]); if (__s1_len > 0
| 0 | ||||||||||||||||||||||||
| 1135 | s
| 0 | ||||||||||||||||||||||||
| 1136 | ))[1] - __s2[1]); if (__s1_len > 1
| 0 | ||||||||||||||||||||||||
| 1137 | s
| 0 | ||||||||||||||||||||||||
| 1138 | ))[2] - __s2[2]); if (__s1_len > 2
never executed: __result = (((const unsigned char *) (const char *) ( s ))[3] - __s2[3]); | 0 | ||||||||||||||||||||||||
| 1139 | s
never executed: __result = (((const unsigned char *) (const char *) ( s ))[3] - __s2[3]); | 0 | ||||||||||||||||||||||||
| 1140 | ))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p (
| 0 | ||||||||||||||||||||||||
| 1141 | "inherit"
| 0 | ||||||||||||||||||||||||
| 1142 | ) && ((size_t)(const void *)((
| 0 | ||||||||||||||||||||||||
| 1143 | "inherit"
| 0 | ||||||||||||||||||||||||
| 1144 | ) + 1) - (size_t)(const void *)(
| 0 | ||||||||||||||||||||||||
| 1145 | "inherit"
| 0 | ||||||||||||||||||||||||
| 1146 | ) == 1) && (__s2_len = __builtin_strlen (
| 0 | ||||||||||||||||||||||||
| 1147 | "inherit"
| 0 | ||||||||||||||||||||||||
| 1148 | ), __s2_len < 4) ? (__builtin_constant_p (
| 0 | ||||||||||||||||||||||||
| 1149 | s
| 0 | ||||||||||||||||||||||||
| 1150 | ) && ((size_t)(const void *)((
| 0 | ||||||||||||||||||||||||
| 1151 | s
| 0 | ||||||||||||||||||||||||
| 1152 | ) + 1) - (size_t)(const void *)(
| 0 | ||||||||||||||||||||||||
| 1153 | s
| 0 | ||||||||||||||||||||||||
| 1154 | ) == 1) ? __builtin_strcmp (
| 0 | ||||||||||||||||||||||||
| 1155 | s
| 0 | ||||||||||||||||||||||||
| 1156 | ,
| 0 | ||||||||||||||||||||||||
| 1157 | "inherit"
| 0 | ||||||||||||||||||||||||
| 1158 | ) : -(__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (
| 0 | ||||||||||||||||||||||||
| 1159 | s
| 0 | ||||||||||||||||||||||||
| 1160 | ); int __result = (((const unsigned char *) (const char *) (
| 0 | ||||||||||||||||||||||||
| 1161 | "inherit"
| 0 | ||||||||||||||||||||||||
| 1162 | ))[0] - __s2[0]); if (__s2_len > 0
| 0 | ||||||||||||||||||||||||
| 1163 | "inherit"
| 0 | ||||||||||||||||||||||||
| 1164 | ))[1] - __s2[1]); if (__s2_len > 1
| 0 | ||||||||||||||||||||||||
| 1165 | "inherit"
| 0 | ||||||||||||||||||||||||
| 1166 | ))[2] - __s2[2]); if (__s2_len > 2
never executed: __result = (((const unsigned char *) (const char *) ( "inherit" ))[3] - __s2[3]); | 0 | ||||||||||||||||||||||||
| 1167 | "inherit"
never executed: __result = (((const unsigned char *) (const char *) ( "inherit" ))[3] - __s2[3]); | 0 | ||||||||||||||||||||||||
| 1168 | ))[3] - __s2[3]); } } __result; }))) : __builtin_strcmp (
| 0 | ||||||||||||||||||||||||
| 1169 | s
| 0 | ||||||||||||||||||||||||
| 1170 | ,
| 0 | ||||||||||||||||||||||||
| 1171 | "inherit"
| 0 | ||||||||||||||||||||||||
| 1172 | )))); })
| 0 | ||||||||||||||||||||||||
| 1173 | == 0
| 0 | ||||||||||||||||||||||||
| 1174 | if (!X509v3_addr_add_inherit(addr, afi, safi)
| 0 | ||||||||||||||||||||||||
| 1175 | ERR_put_error(34,(159),(165),__FILE__,966) | - | ||||||||||||||||||||||||
| 1176 | ; | - | ||||||||||||||||||||||||
| 1177 | ERR_add_error_data(6, "section:", (val)->section, ",name:", (val)->name, ",value:", (val)->value); | - | ||||||||||||||||||||||||
| 1178 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 1179 | } | - | ||||||||||||||||||||||||
| 1180 | CRYPTO_free(s, __FILE__, 970); | - | ||||||||||||||||||||||||
| 1181 | s = | - | ||||||||||||||||||||||||
| 1182 | ((void *)0) | - | ||||||||||||||||||||||||
| 1183 | ; | - | ||||||||||||||||||||||||
| 1184 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 1185 | } | - | ||||||||||||||||||||||||
| 1186 | - | |||||||||||||||||||||||||
| 1187 | i1 = | - | ||||||||||||||||||||||||
| 1188 | __builtin_strspn ( | - | ||||||||||||||||||||||||
| 1189 | s | - | ||||||||||||||||||||||||
| 1190 | , | - | ||||||||||||||||||||||||
| 1191 | addr_chars | - | ||||||||||||||||||||||||
| 1192 | ) | - | ||||||||||||||||||||||||
| 1193 | ; | - | ||||||||||||||||||||||||
| 1194 | i2 = i1 + | - | ||||||||||||||||||||||||
| 1195 | __builtin_strspn ( | - | ||||||||||||||||||||||||
| 1196 | s + i1 | - | ||||||||||||||||||||||||
| 1197 | , | - | ||||||||||||||||||||||||
| 1198 | " \t" | - | ||||||||||||||||||||||||
| 1199 | ) | - | ||||||||||||||||||||||||
| 1200 | ; | - | ||||||||||||||||||||||||
| 1201 | delim = s[i2++]; | - | ||||||||||||||||||||||||
| 1202 | s[i1] = '\0'; | - | ||||||||||||||||||||||||
| 1203 | - | |||||||||||||||||||||||||
| 1204 | if (a2i_ipadd(min, s) != length
| 0 | ||||||||||||||||||||||||
| 1205 | ERR_put_error(34,(159),(166),__FILE__,981); | - | ||||||||||||||||||||||||
| 1206 | ERR_add_error_data(6, "section:", (val)->section, ",name:", (val)->name, ",value:", (val)->value); | - | ||||||||||||||||||||||||
| 1207 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 1208 | } | - | ||||||||||||||||||||||||
| 1209 | - | |||||||||||||||||||||||||
| 1210 | switch (delim) { | - | ||||||||||||||||||||||||
| 1211 | case never executed: '/':case '/':never executed: case '/': | 0 | ||||||||||||||||||||||||
| 1212 | prefixlen = (int)strtoul(s + i2, &t, 10); | - | ||||||||||||||||||||||||
| 1213 | if (t == s + i2
| 0 | ||||||||||||||||||||||||
| 1214 | ERR_put_error(34,(159),(116),__FILE__,991) | - | ||||||||||||||||||||||||
| 1215 | ; | - | ||||||||||||||||||||||||
| 1216 | ERR_add_error_data(6, "section:", (val)->section, ",name:", (val)->name, ",value:", (val)->value); | - | ||||||||||||||||||||||||
| 1217 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 1218 | } | - | ||||||||||||||||||||||||
| 1219 | if (!X509v3_addr_add_prefix(addr, afi, safi, min, prefixlen)
| 0 | ||||||||||||||||||||||||
| 1220 | ERR_put_error(34,(159),((1|64)),__FILE__,996); | - | ||||||||||||||||||||||||
| 1221 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 1222 | } | - | ||||||||||||||||||||||||
| 1223 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 1224 | case never executed: '-':case '-':never executed: case '-': | 0 | ||||||||||||||||||||||||
| 1225 | i1 = i2 + | - | ||||||||||||||||||||||||
| 1226 | __builtin_strspn ( | - | ||||||||||||||||||||||||
| 1227 | s + i2 | - | ||||||||||||||||||||||||
| 1228 | , | - | ||||||||||||||||||||||||
| 1229 | " \t" | - | ||||||||||||||||||||||||
| 1230 | ) | - | ||||||||||||||||||||||||
| 1231 | ; | - | ||||||||||||||||||||||||
| 1232 | i2 = i1 + | - | ||||||||||||||||||||||||
| 1233 | __builtin_strspn ( | - | ||||||||||||||||||||||||
| 1234 | s + i1 | - | ||||||||||||||||||||||||
| 1235 | , | - | ||||||||||||||||||||||||
| 1236 | addr_chars | - | ||||||||||||||||||||||||
| 1237 | ) | - | ||||||||||||||||||||||||
| 1238 | ; | - | ||||||||||||||||||||||||
| 1239 | if (i1 == i2
| 0 | ||||||||||||||||||||||||
| 1240 | ERR_put_error(34,(159),(116),__FILE__,1005) | - | ||||||||||||||||||||||||
| 1241 | ; | - | ||||||||||||||||||||||||
| 1242 | ERR_add_error_data(6, "section:", (val)->section, ",name:", (val)->name, ",value:", (val)->value); | - | ||||||||||||||||||||||||
| 1243 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 1244 | } | - | ||||||||||||||||||||||||
| 1245 | if (a2i_ipadd(max, s + i1) != length
| 0 | ||||||||||||||||||||||||
| 1246 | ERR_put_error(34,(159),(166),__FILE__,1011) | - | ||||||||||||||||||||||||
| 1247 | ; | - | ||||||||||||||||||||||||
| 1248 | ERR_add_error_data(6, "section:", (val)->section, ",name:", (val)->name, ",value:", (val)->value); | - | ||||||||||||||||||||||||
| 1249 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 1250 | } | - | ||||||||||||||||||||||||
| 1251 | if (memcmp(min, max, length_from_afi(afi)) > 0
| 0 | ||||||||||||||||||||||||
| 1252 | ERR_put_error(34,(159),(116),__FILE__,1017) | - | ||||||||||||||||||||||||
| 1253 | ; | - | ||||||||||||||||||||||||
| 1254 | ERR_add_error_data(6, "section:", (val)->section, ",name:", (val)->name, ",value:", (val)->value); | - | ||||||||||||||||||||||||
| 1255 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 1256 | } | - | ||||||||||||||||||||||||
| 1257 | if (!X509v3_addr_add_range(addr, afi, safi, min, max)
| 0 | ||||||||||||||||||||||||
| 1258 | ERR_put_error(34,(159),((1|64)),__FILE__,1022); | - | ||||||||||||||||||||||||
| 1259 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 1260 | } | - | ||||||||||||||||||||||||
| 1261 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 1262 | case never executed: '\0':case '\0':never executed: case '\0': | 0 | ||||||||||||||||||||||||
| 1263 | if (!X509v3_addr_add_prefix(addr, afi, safi, min, length * 8)
| 0 | ||||||||||||||||||||||||
| 1264 | ERR_put_error(34,(159),((1|64)),__FILE__,1028); | - | ||||||||||||||||||||||||
| 1265 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 1266 | } | - | ||||||||||||||||||||||||
| 1267 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 1268 | default never executed: :default:never executed: default: | 0 | ||||||||||||||||||||||||
| 1269 | ERR_put_error(34,(159),(116),__FILE__,1034) | - | ||||||||||||||||||||||||
| 1270 | ; | - | ||||||||||||||||||||||||
| 1271 | ERR_add_error_data(6, "section:", (val)->section, ",name:", (val)->name, ",value:", (val)->value); | - | ||||||||||||||||||||||||
| 1272 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 1273 | } | - | ||||||||||||||||||||||||
| 1274 | - | |||||||||||||||||||||||||
| 1275 | CRYPTO_free(s, __FILE__, 1039); | - | ||||||||||||||||||||||||
| 1276 | s = | - | ||||||||||||||||||||||||
| 1277 | ((void *)0) | - | ||||||||||||||||||||||||
| 1278 | ; | - | ||||||||||||||||||||||||
| 1279 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1280 | - | |||||||||||||||||||||||||
| 1281 | - | |||||||||||||||||||||||||
| 1282 | - | |||||||||||||||||||||||||
| 1283 | - | |||||||||||||||||||||||||
| 1284 | if (!X509v3_addr_canonize(addr)
| 0 | ||||||||||||||||||||||||
| 1285 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 1286 | return never executed: addr;return addr;never executed: return addr; | 0 | ||||||||||||||||||||||||
| 1287 | - | |||||||||||||||||||||||||
| 1288 | err: | - | ||||||||||||||||||||||||
| 1289 | CRYPTO_free(s, __FILE__, 1051); | - | ||||||||||||||||||||||||
| 1290 | sk_IPAddressFamily_pop_free(addr, IPAddressFamily_free); | - | ||||||||||||||||||||||||
| 1291 | return never executed: return ((void *)0) ;never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||
| 1292 | ((void *)0) never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||
| 1293 | ; never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||
| 1294 | } | - | ||||||||||||||||||||||||
| 1295 | - | |||||||||||||||||||||||||
| 1296 | - | |||||||||||||||||||||||||
| 1297 | - | |||||||||||||||||||||||||
| 1298 | - | |||||||||||||||||||||||||
| 1299 | const X509V3_EXT_METHOD v3_addr = { | - | ||||||||||||||||||||||||
| 1300 | 290, | - | ||||||||||||||||||||||||
| 1301 | 0, | - | ||||||||||||||||||||||||
| 1302 | (&(IPAddrBlocks_it)), | - | ||||||||||||||||||||||||
| 1303 | 0, 0, 0, 0, | - | ||||||||||||||||||||||||
| 1304 | 0, | - | ||||||||||||||||||||||||
| 1305 | 0, | - | ||||||||||||||||||||||||
| 1306 | 0, | - | ||||||||||||||||||||||||
| 1307 | v2i_IPAddrBlocks, | - | ||||||||||||||||||||||||
| 1308 | i2r_IPAddrBlocks, | - | ||||||||||||||||||||||||
| 1309 | 0, | - | ||||||||||||||||||||||||
| 1310 | - | |||||||||||||||||||||||||
| 1311 | ((void *)0) | - | ||||||||||||||||||||||||
| 1312 | - | |||||||||||||||||||||||||
| 1313 | }; | - | ||||||||||||||||||||||||
| 1314 | - | |||||||||||||||||||||||||
| 1315 | - | |||||||||||||||||||||||||
| 1316 | - | |||||||||||||||||||||||||
| 1317 | - | |||||||||||||||||||||||||
| 1318 | int X509v3_addr_inherits(IPAddrBlocks *addr) | - | ||||||||||||||||||||||||
| 1319 | { | - | ||||||||||||||||||||||||
| 1320 | int i; | - | ||||||||||||||||||||||||
| 1321 | if (addr ==
| 0 | ||||||||||||||||||||||||
| 1322 | ((void *)0)
| 0 | ||||||||||||||||||||||||
| 1323 | ) | - | ||||||||||||||||||||||||
| 1324 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 1325 | for (i = 0; i < sk_IPAddressFamily_num(addr)
| 0 | ||||||||||||||||||||||||
| 1326 | IPAddressFamily *f = sk_IPAddressFamily_value(addr, i); | - | ||||||||||||||||||||||||
| 1327 | if (f->ipAddressChoice->type == 0
| 0 | ||||||||||||||||||||||||
| 1328 | return never executed: 1;return 1;never executed: return 1; | 0 | ||||||||||||||||||||||||
| 1329 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1330 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 1331 | } | - | ||||||||||||||||||||||||
| 1332 | - | |||||||||||||||||||||||||
| 1333 | - | |||||||||||||||||||||||||
| 1334 | - | |||||||||||||||||||||||||
| 1335 | - | |||||||||||||||||||||||||
| 1336 | static int addr_contains(IPAddressOrRanges *parent, | - | ||||||||||||||||||||||||
| 1337 | IPAddressOrRanges *child, int length) | - | ||||||||||||||||||||||||
| 1338 | { | - | ||||||||||||||||||||||||
| 1339 | unsigned char p_min[16], p_max[16]; | - | ||||||||||||||||||||||||
| 1340 | unsigned char c_min[16], c_max[16]; | - | ||||||||||||||||||||||||
| 1341 | int p, c; | - | ||||||||||||||||||||||||
| 1342 | - | |||||||||||||||||||||||||
| 1343 | if (child ==
| 0 | ||||||||||||||||||||||||
| 1344 | ((void *)0)
| 0 | ||||||||||||||||||||||||
| 1345 | || parent == child
| 0 | ||||||||||||||||||||||||
| 1346 | return never executed: 1;return 1;never executed: return 1; | 0 | ||||||||||||||||||||||||
| 1347 | if (parent ==
| 0 | ||||||||||||||||||||||||
| 1348 | ((void *)0)
| 0 | ||||||||||||||||||||||||
| 1349 | ) | - | ||||||||||||||||||||||||
| 1350 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 1351 | - | |||||||||||||||||||||||||
| 1352 | p = 0; | - | ||||||||||||||||||||||||
| 1353 | for (c = 0; c < sk_IPAddressOrRange_num(child)
| 0 | ||||||||||||||||||||||||
| 1354 | if (!extract_min_max(sk_IPAddressOrRange_value(child, c),
| 0 | ||||||||||||||||||||||||
| 1355 | c_min, c_max, length)
| 0 | ||||||||||||||||||||||||
| 1356 | return never executed: -1;return -1;never executed: return -1; | 0 | ||||||||||||||||||||||||
| 1357 | for (;; p++) { | - | ||||||||||||||||||||||||
| 1358 | if (p >= sk_IPAddressOrRange_num(parent)
| 0 | ||||||||||||||||||||||||
| 1359 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 1360 | if (!extract_min_max(sk_IPAddressOrRange_value(parent, p),
| 0 | ||||||||||||||||||||||||
| 1361 | p_min, p_max, length)
| 0 | ||||||||||||||||||||||||
| 1362 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 1363 | if (memcmp(p_max, c_max, length) < 0
| 0 | ||||||||||||||||||||||||
| 1364 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 1365 | if (memcmp(p_min, c_min, length) > 0
| 0 | ||||||||||||||||||||||||
| 1366 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 1367 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 1368 | } | - | ||||||||||||||||||||||||
| 1369 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1370 | - | |||||||||||||||||||||||||
| 1371 | return never executed: 1;return 1;never executed: return 1; | 0 | ||||||||||||||||||||||||
| 1372 | } | - | ||||||||||||||||||||||||
| 1373 | - | |||||||||||||||||||||||||
| 1374 | - | |||||||||||||||||||||||||
| 1375 | - | |||||||||||||||||||||||||
| 1376 | - | |||||||||||||||||||||||||
| 1377 | int X509v3_addr_subset(IPAddrBlocks *a, IPAddrBlocks *b) | - | ||||||||||||||||||||||||
| 1378 | { | - | ||||||||||||||||||||||||
| 1379 | int i; | - | ||||||||||||||||||||||||
| 1380 | if (a ==
| 0 | ||||||||||||||||||||||||
| 1381 | ((void *)0)
| 0 | ||||||||||||||||||||||||
| 1382 | || a == b
| 0 | ||||||||||||||||||||||||
| 1383 | return never executed: 1;return 1;never executed: return 1; | 0 | ||||||||||||||||||||||||
| 1384 | if (b ==
| 0 | ||||||||||||||||||||||||
| 1385 | ((void *)0)
| 0 | ||||||||||||||||||||||||
| 1386 | || X509v3_addr_inherits(a)
| 0 | ||||||||||||||||||||||||
| 1387 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 1388 | (void)sk_IPAddressFamily_set_cmp_func(b, IPAddressFamily_cmp); | - | ||||||||||||||||||||||||
| 1389 | for (i = 0; i < sk_IPAddressFamily_num(a)
| 0 | ||||||||||||||||||||||||
| 1390 | IPAddressFamily *fa = sk_IPAddressFamily_value(a, i); | - | ||||||||||||||||||||||||
| 1391 | int j = sk_IPAddressFamily_find(b, fa); | - | ||||||||||||||||||||||||
| 1392 | IPAddressFamily *fb; | - | ||||||||||||||||||||||||
| 1393 | fb = sk_IPAddressFamily_value(b, j); | - | ||||||||||||||||||||||||
| 1394 | if (fb ==
| 0 | ||||||||||||||||||||||||
| 1395 | ((void *)0)
| 0 | ||||||||||||||||||||||||
| 1396 | ) | - | ||||||||||||||||||||||||
| 1397 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 1398 | if (!addr_contains(fb->ipAddressChoice->u.addressesOrRanges,
| 0 | ||||||||||||||||||||||||
| 1399 | fa->ipAddressChoice->u.addressesOrRanges,
| 0 | ||||||||||||||||||||||||
| 1400 | length_from_afi(X509v3_addr_get_afi(fb)))
| 0 | ||||||||||||||||||||||||
| 1401 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 1402 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1403 | return never executed: 1;return 1;never executed: return 1; | 0 | ||||||||||||||||||||||||
| 1404 | } | - | ||||||||||||||||||||||||
| 1405 | static int addr_validate_path_internal(X509_STORE_CTX *ctx, | - | ||||||||||||||||||||||||
| 1406 | struct stack_st_X509 *chain, | - | ||||||||||||||||||||||||
| 1407 | IPAddrBlocks *ext) | - | ||||||||||||||||||||||||
| 1408 | { | - | ||||||||||||||||||||||||
| 1409 | IPAddrBlocks *child = | - | ||||||||||||||||||||||||
| 1410 | ((void *)0) | - | ||||||||||||||||||||||||
| 1411 | ; | - | ||||||||||||||||||||||||
| 1412 | int i, j, ret = 1; | - | ||||||||||||||||||||||||
| 1413 | X509 *x; | - | ||||||||||||||||||||||||
| 1414 | - | |||||||||||||||||||||||||
| 1415 | if (!((chain !=
| 0-1305 | ||||||||||||||||||||||||
| 1416 | ((void *)0)
| 0-1305 | ||||||||||||||||||||||||
| 1417 | && sk_X509_num(chain) > 0
| 0-1305 | ||||||||||||||||||||||||
| 1418 | || !((ctx !=
| 0-1305 | ||||||||||||||||||||||||
| 1419 | ((void *)0)
| 0-1305 | ||||||||||||||||||||||||
| 1420 | || ext !=
| 0-1305 | ||||||||||||||||||||||||
| 1421 | ((void *)0)
| 0-1305 | ||||||||||||||||||||||||
| 1422 | ) != 0)
| 0-1305 | ||||||||||||||||||||||||
| 1423 | || !((ctx ==
| 0-1305 | ||||||||||||||||||||||||
| 1424 | ((void *)0)
| 0-1305 | ||||||||||||||||||||||||
| 1425 | || ctx->verify_cb !=
| 0-1305 | ||||||||||||||||||||||||
| 1426 | ((void *)0)
| 0-1305 | ||||||||||||||||||||||||
| 1427 | ) != 0)
| 0-1305 | ||||||||||||||||||||||||
| 1428 | if (ctx !=
| 0 | ||||||||||||||||||||||||
| 1429 | ((void *)0)
| 0 | ||||||||||||||||||||||||
| 1430 | ) | - | ||||||||||||||||||||||||
| 1431 | ctx->error = 1; never executed: ctx->error = 1; | 0 | ||||||||||||||||||||||||
| 1432 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 1433 | } | - | ||||||||||||||||||||||||
| 1434 | - | |||||||||||||||||||||||||
| 1435 | - | |||||||||||||||||||||||||
| 1436 | - | |||||||||||||||||||||||||
| 1437 | - | |||||||||||||||||||||||||
| 1438 | - | |||||||||||||||||||||||||
| 1439 | - | |||||||||||||||||||||||||
| 1440 | if (ext !=
| 0-1305 | ||||||||||||||||||||||||
| 1441 | ((void *)0)
| 0-1305 | ||||||||||||||||||||||||
| 1442 | ) { | - | ||||||||||||||||||||||||
| 1443 | i = -1; | - | ||||||||||||||||||||||||
| 1444 | x = | - | ||||||||||||||||||||||||
| 1445 | ((void *)0) | - | ||||||||||||||||||||||||
| 1446 | ; | - | ||||||||||||||||||||||||
| 1447 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 1448 | i = 0; | - | ||||||||||||||||||||||||
| 1449 | x = sk_X509_value(chain, i); | - | ||||||||||||||||||||||||
| 1450 | if ((
| 0-1305 | ||||||||||||||||||||||||
| 1451 | ((void *)0)
| 0-1305 | ||||||||||||||||||||||||
| 1452 | ) | - | ||||||||||||||||||||||||
| 1453 | goto executed 1305 times by 1 test: done;goto done;Executed by:
executed 1305 times by 1 test: goto done;Executed by:
| 1305 | ||||||||||||||||||||||||
| 1454 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1455 | if (!X509v3_addr_is_canonical(ext)
| 0 | ||||||||||||||||||||||||
| 1456 | do { if (ctx !=
| 0 | ||||||||||||||||||||||||
| 1457 | ((void *)0)
| 0 | ||||||||||||||||||||||||
| 1458 | ) { ctx->error = 41; ctx->error_depth = i; ctx->current_cert = x; ret = ctx->verify_cb(0, ctx); } never executed: else { ret = 0; }end of blocknever executed: if (!retend of block
never executed: done;goto done;never executed: }goto done;never executed: while (0);end of block | 0 | ||||||||||||||||||||||||
| 1459 | (void)sk_IPAddressFamily_set_cmp_func(ext, IPAddressFamily_cmp); | - | ||||||||||||||||||||||||
| 1460 | if ((
| 0 | ||||||||||||||||||||||||
| 1461 | ((void *)0)
| 0 | ||||||||||||||||||||||||
| 1462 | ) { | - | ||||||||||||||||||||||||
| 1463 | ERR_put_error(34,(166),((1|64)),__FILE__,1212) | - | ||||||||||||||||||||||||
| 1464 | ; | - | ||||||||||||||||||||||||
| 1465 | if (ctx !=
| 0 | ||||||||||||||||||||||||
| 1466 | ((void *)0)
| 0 | ||||||||||||||||||||||||
| 1467 | ) | - | ||||||||||||||||||||||||
| 1468 | ctx->error = 17; never executed: ctx->error = 17; | 0 | ||||||||||||||||||||||||
| 1469 | ret = 0; | - | ||||||||||||||||||||||||
| 1470 | goto never executed: done;goto done;never executed: goto done; | 0 | ||||||||||||||||||||||||
| 1471 | } | - | ||||||||||||||||||||||||
| 1472 | - | |||||||||||||||||||||||||
| 1473 | - | |||||||||||||||||||||||||
| 1474 | - | |||||||||||||||||||||||||
| 1475 | - | |||||||||||||||||||||||||
| 1476 | - | |||||||||||||||||||||||||
| 1477 | for (i++; i < sk_X509_num(chain)
| 0 | ||||||||||||||||||||||||
| 1478 | x = sk_X509_value(chain, i); | - | ||||||||||||||||||||||||
| 1479 | if (!X509v3_addr_is_canonical(x->rfc3779_addr)
| 0 | ||||||||||||||||||||||||
| 1480 | do { if (ctx !=
| 0 | ||||||||||||||||||||||||
| 1481 | ((void *)0)
| 0 | ||||||||||||||||||||||||
| 1482 | ) { ctx->error = 41; ctx->error_depth = i; ctx->current_cert = x; ret = ctx->verify_cb(0, ctx); } never executed: else { ret = 0; }end of blocknever executed: if (!retend of block
never executed: done;goto done;never executed: }goto done;never executed: while (0);end of block | 0 | ||||||||||||||||||||||||
| 1483 | if (x->rfc3779_addr ==
| 0 | ||||||||||||||||||||||||
| 1484 | ((void *)0)
| 0 | ||||||||||||||||||||||||
| 1485 | ) { | - | ||||||||||||||||||||||||
| 1486 | for (j = 0; j < sk_IPAddressFamily_num(child)
| 0 | ||||||||||||||||||||||||
| 1487 | IPAddressFamily *fc = sk_IPAddressFamily_value(child, j); | - | ||||||||||||||||||||||||
| 1488 | if (fc->ipAddressChoice->type != 0
| 0 | ||||||||||||||||||||||||
| 1489 | do { if (ctx !=
| 0 | ||||||||||||||||||||||||
| 1490 | ((void *)0)
| 0 | ||||||||||||||||||||||||
| 1491 | ) { ctx->error = 46; ctx->error_depth = i; ctx->current_cert = x; ret = ctx->verify_cb(0, ctx); } never executed: else { ret = 0; }end of blocknever executed: if (!retend of block
never executed: done;goto done;never executed: } while (0);goto done; | 0 | ||||||||||||||||||||||||
| 1492 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 1493 | } | - | ||||||||||||||||||||||||
| 1494 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1495 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 1496 | } | - | ||||||||||||||||||||||||
| 1497 | (void)sk_IPAddressFamily_set_cmp_func(x->rfc3779_addr, | - | ||||||||||||||||||||||||
| 1498 | IPAddressFamily_cmp); | - | ||||||||||||||||||||||||
| 1499 | for (j = 0; j < sk_IPAddressFamily_num(child)
| 0 | ||||||||||||||||||||||||
| 1500 | IPAddressFamily *fc = sk_IPAddressFamily_value(child, j); | - | ||||||||||||||||||||||||
| 1501 | int k = sk_IPAddressFamily_find(x->rfc3779_addr, fc); | - | ||||||||||||||||||||||||
| 1502 | IPAddressFamily *fp = | - | ||||||||||||||||||||||||
| 1503 | sk_IPAddressFamily_value(x->rfc3779_addr, k); | - | ||||||||||||||||||||||||
| 1504 | if (fp ==
| 0 | ||||||||||||||||||||||||
| 1505 | ((void *)0)
| 0 | ||||||||||||||||||||||||
| 1506 | ) { | - | ||||||||||||||||||||||||
| 1507 | if (fc->ipAddressChoice->type ==
| 0 | ||||||||||||||||||||||||
| 1508 | 1
| 0 | ||||||||||||||||||||||||
| 1509 | do { if (ctx !=
| 0 | ||||||||||||||||||||||||
| 1510 | ((void *)0)
| 0 | ||||||||||||||||||||||||
| 1511 | ) { ctx->error = 46; ctx->error_depth = i; ctx->current_cert = x; ret = ctx->verify_cb(0, ctx); } never executed: else { ret = 0; }end of blocknever executed: if (!retend of block
never executed: done;goto done;never executed: } while (0);goto done; | 0 | ||||||||||||||||||||||||
| 1512 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 1513 | } | - | ||||||||||||||||||||||||
| 1514 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 1515 | } | - | ||||||||||||||||||||||||
| 1516 | if (fp->ipAddressChoice->type ==
| 0 | ||||||||||||||||||||||||
| 1517 | 1
| 0 | ||||||||||||||||||||||||
| 1518 | if (fc->ipAddressChoice->type == 0
| 0 | ||||||||||||||||||||||||
| 1519 | || addr_contains(fp->ipAddressChoice->u.addressesOrRanges,
| 0 | ||||||||||||||||||||||||
| 1520 | fc->ipAddressChoice->u.addressesOrRanges,
| 0 | ||||||||||||||||||||||||
| 1521 | length_from_afi(X509v3_addr_get_afi(fc)))
| 0 | ||||||||||||||||||||||||
| 1522 | sk_IPAddressFamily_set(child, j, fp); never executed: sk_IPAddressFamily_set(child, j, fp); | 0 | ||||||||||||||||||||||||
| 1523 | else | - | ||||||||||||||||||||||||
| 1524 | do { if (ctx !=
| 0 | ||||||||||||||||||||||||
| 1525 | ((void *)0)
| 0 | ||||||||||||||||||||||||
| 1526 | ) { ctx->error = 46; ctx->error_depth = i; ctx->current_cert = x; ret = ctx->verify_cb(0, ctx); } never executed: else { ret = 0; }end of blocknever executed: if (!retend of block
never executed: done;goto done;never executed: }goto done;never executed: while (0);end of block | 0 | ||||||||||||||||||||||||
| 1527 | } | - | ||||||||||||||||||||||||
| 1528 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1529 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1530 | - | |||||||||||||||||||||||||
| 1531 | - | |||||||||||||||||||||||||
| 1532 | - | |||||||||||||||||||||||||
| 1533 | - | |||||||||||||||||||||||||
| 1534 | if (x->rfc3779_addr !=
| 0 | ||||||||||||||||||||||||
| 1535 | ((void *)0)
| 0 | ||||||||||||||||||||||||
| 1536 | ) { | - | ||||||||||||||||||||||||
| 1537 | for (j = 0; j < sk_IPAddressFamily_num(x->rfc3779_addr)
| 0 | ||||||||||||||||||||||||
| 1538 | IPAddressFamily *fp = | - | ||||||||||||||||||||||||
| 1539 | sk_IPAddressFamily_value(x->rfc3779_addr, j); | - | ||||||||||||||||||||||||
| 1540 | if (fp->ipAddressChoice->type == 0
| 0 | ||||||||||||||||||||||||
| 1541 | && sk_IPAddressFamily_find(child, fp) >= 0
| 0 | ||||||||||||||||||||||||
| 1542 | do { if (ctx !=
| 0 | ||||||||||||||||||||||||
| 1543 | ((void *)0)
| 0 | ||||||||||||||||||||||||
| 1544 | ) { ctx->error = 46; ctx->error_depth = i; ctx->current_cert = x; ret = ctx->verify_cb(0, ctx); } never executed: else { ret = 0; }end of blocknever executed: if (!retend of block
never executed: done;goto done;never executed: }goto done;never executed: while (0);end of block | 0 | ||||||||||||||||||||||||
| 1545 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1546 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1547 | - | |||||||||||||||||||||||||
| 1548 | done: code before this statement never executed: done: | 0 | ||||||||||||||||||||||||
| 1549 | sk_IPAddressFamily_free(child); | - | ||||||||||||||||||||||||
| 1550 | return executed 1305 times by 1 test: ret;return ret;Executed by:
executed 1305 times by 1 test: return ret;Executed by:
| 1305 | ||||||||||||||||||||||||
| 1551 | } | - | ||||||||||||||||||||||||
| 1552 | - | |||||||||||||||||||||||||
| 1553 | - | |||||||||||||||||||||||||
| 1554 | - | |||||||||||||||||||||||||
| 1555 | - | |||||||||||||||||||||||||
| 1556 | - | |||||||||||||||||||||||||
| 1557 | - | |||||||||||||||||||||||||
| 1558 | int X509v3_addr_validate_path(X509_STORE_CTX *ctx) | - | ||||||||||||||||||||||||
| 1559 | { | - | ||||||||||||||||||||||||
| 1560 | if (ctx->chain ==
| 0-1305 | ||||||||||||||||||||||||
| 1561 | ((void *)0)
| 0-1305 | ||||||||||||||||||||||||
| 1562 | - | |||||||||||||||||||||||||
| 1563 | || sk_X509_num(ctx->chain) == 0
| 0-1305 | ||||||||||||||||||||||||
| 1564 | || ctx->verify_cb ==
| 0-1305 | ||||||||||||||||||||||||
| 1565 | ((void *)0)
| 0-1305 | ||||||||||||||||||||||||
| 1566 | ) { | - | ||||||||||||||||||||||||
| 1567 | ctx->error = 1; | - | ||||||||||||||||||||||||
| 1568 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 1569 | } | - | ||||||||||||||||||||||||
| 1570 | return executed 1305 times by 1 test: addr_validate_path_internal(ctx, ctx->chain, return addr_validate_path_internal(ctx, ctx->chain, ((void *)0) );Executed by:
executed 1305 times by 1 test: return addr_validate_path_internal(ctx, ctx->chain, ((void *)0) );Executed by:
| 1305 | ||||||||||||||||||||||||
| 1571 | ((void *)0) executed 1305 times by 1 test: return addr_validate_path_internal(ctx, ctx->chain, ((void *)0) );Executed by:
| 1305 | ||||||||||||||||||||||||
| 1572 | ); executed 1305 times by 1 test: return addr_validate_path_internal(ctx, ctx->chain, ((void *)0) );Executed by:
| 1305 | ||||||||||||||||||||||||
| 1573 | } | - | ||||||||||||||||||||||||
| 1574 | - | |||||||||||||||||||||||||
| 1575 | - | |||||||||||||||||||||||||
| 1576 | - | |||||||||||||||||||||||||
| 1577 | - | |||||||||||||||||||||||||
| 1578 | - | |||||||||||||||||||||||||
| 1579 | int X509v3_addr_validate_resource_set(struct stack_st_X509 *chain, | - | ||||||||||||||||||||||||
| 1580 | IPAddrBlocks *ext, int allow_inheritance) | - | ||||||||||||||||||||||||
| 1581 | { | - | ||||||||||||||||||||||||
| 1582 | if (ext ==
| 0 | ||||||||||||||||||||||||
| 1583 | ((void *)0)
| 0 | ||||||||||||||||||||||||
| 1584 | ) | - | ||||||||||||||||||||||||
| 1585 | return never executed: 1;return 1;never executed: return 1; | 0 | ||||||||||||||||||||||||
| 1586 | if (chain ==
| 0 | ||||||||||||||||||||||||
| 1587 | ((void *)0)
| 0 | ||||||||||||||||||||||||
| 1588 | || sk_X509_num(chain) == 0
| 0 | ||||||||||||||||||||||||
| 1589 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 1590 | if (!allow_inheritance
| 0 | ||||||||||||||||||||||||
| 1591 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 1592 | return never executed: addr_validate_path_internal(return addr_validate_path_internal( ((void *)0) , chain, ext);never executed: return addr_validate_path_internal( ((void *)0) , chain, ext); | 0 | ||||||||||||||||||||||||
| 1593 | ((void *)0) never executed: return addr_validate_path_internal( ((void *)0) , chain, ext); | 0 | ||||||||||||||||||||||||
| 1594 | , chain, ext); never executed: return addr_validate_path_internal( ((void *)0) , chain, ext); | 0 | ||||||||||||||||||||||||
| 1595 | } | - | ||||||||||||||||||||||||
| Switch to Source code | Preprocessed file |