| Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/openssh/src/addrmatch.c |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||||||||||||||||||||
| 2 | - | |||||||||||||||||||||||||||||||
| 3 | - | |||||||||||||||||||||||||||||||
| 4 | - | |||||||||||||||||||||||||||||||
| 5 | - | |||||||||||||||||||||||||||||||
| 6 | - | |||||||||||||||||||||||||||||||
| 7 | - | |||||||||||||||||||||||||||||||
| 8 | - | |||||||||||||||||||||||||||||||
| 9 | - | |||||||||||||||||||||||||||||||
| 10 | - | |||||||||||||||||||||||||||||||
| 11 | struct xaddr { | - | ||||||||||||||||||||||||||||||
| 12 | sa_family_t af; | - | ||||||||||||||||||||||||||||||
| 13 | union { | - | ||||||||||||||||||||||||||||||
| 14 | struct in_addr v4; | - | ||||||||||||||||||||||||||||||
| 15 | struct in6_addr v6; | - | ||||||||||||||||||||||||||||||
| 16 | u_int8_t addr8[16]; | - | ||||||||||||||||||||||||||||||
| 17 | u_int32_t addr32[4]; | - | ||||||||||||||||||||||||||||||
| 18 | } xa; | - | ||||||||||||||||||||||||||||||
| 19 | u_int32_t scope_id; | - | ||||||||||||||||||||||||||||||
| 20 | - | |||||||||||||||||||||||||||||||
| 21 | - | |||||||||||||||||||||||||||||||
| 22 | - | |||||||||||||||||||||||||||||||
| 23 | - | |||||||||||||||||||||||||||||||
| 24 | }; | - | ||||||||||||||||||||||||||||||
| 25 | - | |||||||||||||||||||||||||||||||
| 26 | static int | - | ||||||||||||||||||||||||||||||
| 27 | addr_unicast_masklen(int af) | - | ||||||||||||||||||||||||||||||
| 28 | { | - | ||||||||||||||||||||||||||||||
| 29 | switch (af) { | - | ||||||||||||||||||||||||||||||
| 30 | case executed 10 times by 1 test: case 2 :Executed by:
executed 10 times by 1 test: case 2 :Executed by:
| 10 | ||||||||||||||||||||||||||||||
| 31 | 2 executed 10 times by 1 test: case 2 :Executed by:
| 10 | ||||||||||||||||||||||||||||||
| 32 | : executed 10 times by 1 test: case 2 :Executed by:
| 10 | ||||||||||||||||||||||||||||||
| 33 | return executed 10 times by 1 test: 32;return 32;Executed by:
executed 10 times by 1 test: return 32;Executed by:
| 10 | ||||||||||||||||||||||||||||||
| 34 | case never executed: case 10 :never executed: case 10 : | 0 | ||||||||||||||||||||||||||||||
| 35 | 10 never executed: case 10 : | 0 | ||||||||||||||||||||||||||||||
| 36 | : never executed: case 10 : | 0 | ||||||||||||||||||||||||||||||
| 37 | return never executed: 128;return 128;never executed: return 128; | 0 | ||||||||||||||||||||||||||||||
| 38 | default never executed: :default:never executed: default: | 0 | ||||||||||||||||||||||||||||||
| 39 | return never executed: -1;return -1;never executed: return -1; | 0 | ||||||||||||||||||||||||||||||
| 40 | } | - | ||||||||||||||||||||||||||||||
| 41 | } | - | ||||||||||||||||||||||||||||||
| 42 | - | |||||||||||||||||||||||||||||||
| 43 | static inline int | - | ||||||||||||||||||||||||||||||
| 44 | masklen_valid(int af, u_int masklen) | - | ||||||||||||||||||||||||||||||
| 45 | { | - | ||||||||||||||||||||||||||||||
| 46 | switch (af) { | - | ||||||||||||||||||||||||||||||
| 47 | case executed 47 times by 1 test: case 2 :Executed by:
executed 47 times by 1 test: case 2 :Executed by:
| 47 | ||||||||||||||||||||||||||||||
| 48 | 2 executed 47 times by 1 test: case 2 :Executed by:
| 47 | ||||||||||||||||||||||||||||||
| 49 | : executed 47 times by 1 test: case 2 :Executed by:
| 47 | ||||||||||||||||||||||||||||||
| 50 | return executed 47 times by 1 test: masklen <= 32return masklen <= 32 ? 0 : -1;Executed by:
executed 47 times by 1 test: return masklen <= 32 ? 0 : -1;Executed by:
| 2-47 | ||||||||||||||||||||||||||||||
| 51 | case never executed: case 10 :never executed: case 10 : | 0 | ||||||||||||||||||||||||||||||
| 52 | 10 never executed: case 10 : | 0 | ||||||||||||||||||||||||||||||
| 53 | : never executed: case 10 : | 0 | ||||||||||||||||||||||||||||||
| 54 | return never executed: masklen <= 128return masklen <= 128 ? 0 : -1;
never executed: return masklen <= 128 ? 0 : -1; | 0 | ||||||||||||||||||||||||||||||
| 55 | default never executed: :default:never executed: default: | 0 | ||||||||||||||||||||||||||||||
| 56 | return never executed: -1;return -1;never executed: return -1; | 0 | ||||||||||||||||||||||||||||||
| 57 | } | - | ||||||||||||||||||||||||||||||
| 58 | } | - | ||||||||||||||||||||||||||||||
| 59 | - | |||||||||||||||||||||||||||||||
| 60 | - | |||||||||||||||||||||||||||||||
| 61 | - | |||||||||||||||||||||||||||||||
| 62 | - | |||||||||||||||||||||||||||||||
| 63 | - | |||||||||||||||||||||||||||||||
| 64 | static int | - | ||||||||||||||||||||||||||||||
| 65 | addr_sa_to_xaddr(struct sockaddr *sa, socklen_t slen, struct xaddr *xa) | - | ||||||||||||||||||||||||||||||
| 66 | { | - | ||||||||||||||||||||||||||||||
| 67 | struct sockaddr_in *in4 = (struct sockaddr_in *)sa; | - | ||||||||||||||||||||||||||||||
| 68 | struct sockaddr_in6 *in6 = (struct sockaddr_in6 *)sa; | - | ||||||||||||||||||||||||||||||
| 69 | - | |||||||||||||||||||||||||||||||
| 70 | memset(xa, '\0', sizeof(*xa)); | - | ||||||||||||||||||||||||||||||
| 71 | - | |||||||||||||||||||||||||||||||
| 72 | switch (sa->sa_family) { | - | ||||||||||||||||||||||||||||||
| 73 | case executed 31 times by 1 test: case 2 :Executed by:
executed 31 times by 1 test: case 2 :Executed by:
| 31 | ||||||||||||||||||||||||||||||
| 74 | 2 executed 31 times by 1 test: case 2 :Executed by:
| 31 | ||||||||||||||||||||||||||||||
| 75 | : executed 31 times by 1 test: case 2 :Executed by:
| 31 | ||||||||||||||||||||||||||||||
| 76 | if (slen < (socklen_t)sizeof(*in4)
| 0-31 | ||||||||||||||||||||||||||||||
| 77 | return never executed: -1;return -1;never executed: return -1; | 0 | ||||||||||||||||||||||||||||||
| 78 | xa->af = | - | ||||||||||||||||||||||||||||||
| 79 | 2 | - | ||||||||||||||||||||||||||||||
| 80 | ; | - | ||||||||||||||||||||||||||||||
| 81 | memcpy(&xa->xa.v4, &in4->sin_addr, sizeof(xa->xa.v4)); | - | ||||||||||||||||||||||||||||||
| 82 | break; executed 31 times by 1 test: break;Executed by:
| 31 | ||||||||||||||||||||||||||||||
| 83 | case never executed: case 10 :never executed: case 10 : | 0 | ||||||||||||||||||||||||||||||
| 84 | 10 never executed: case 10 : | 0 | ||||||||||||||||||||||||||||||
| 85 | : never executed: case 10 : | 0 | ||||||||||||||||||||||||||||||
| 86 | if (slen < (socklen_t)sizeof(*in6)
| 0 | ||||||||||||||||||||||||||||||
| 87 | return never executed: -1;return -1;never executed: return -1; | 0 | ||||||||||||||||||||||||||||||
| 88 | xa->af = | - | ||||||||||||||||||||||||||||||
| 89 | 10 | - | ||||||||||||||||||||||||||||||
| 90 | ; | - | ||||||||||||||||||||||||||||||
| 91 | memcpy(&xa->xa.v6, &in6->sin6_addr, sizeof(xa->xa.v6)); | - | ||||||||||||||||||||||||||||||
| 92 | - | |||||||||||||||||||||||||||||||
| 93 | xa->scope_id = in6->sin6_scope_id; | - | ||||||||||||||||||||||||||||||
| 94 | - | |||||||||||||||||||||||||||||||
| 95 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||
| 96 | default never executed: :default:never executed: default: | 0 | ||||||||||||||||||||||||||||||
| 97 | return never executed: -1;return -1;never executed: return -1; | 0 | ||||||||||||||||||||||||||||||
| 98 | } | - | ||||||||||||||||||||||||||||||
| 99 | - | |||||||||||||||||||||||||||||||
| 100 | return executed 31 times by 1 test: 0;return 0;Executed by:
executed 31 times by 1 test: return 0;Executed by:
| 31 | ||||||||||||||||||||||||||||||
| 101 | } | - | ||||||||||||||||||||||||||||||
| 102 | - | |||||||||||||||||||||||||||||||
| 103 | - | |||||||||||||||||||||||||||||||
| 104 | - | |||||||||||||||||||||||||||||||
| 105 | - | |||||||||||||||||||||||||||||||
| 106 | - | |||||||||||||||||||||||||||||||
| 107 | - | |||||||||||||||||||||||||||||||
| 108 | static int | - | ||||||||||||||||||||||||||||||
| 109 | addr_netmask(int af, u_int l, struct xaddr *n) | - | ||||||||||||||||||||||||||||||
| 110 | { | - | ||||||||||||||||||||||||||||||
| 111 | int i; | - | ||||||||||||||||||||||||||||||
| 112 | - | |||||||||||||||||||||||||||||||
| 113 | if (masklen_valid(af, l) != 0
| 0-30 | ||||||||||||||||||||||||||||||
| 114 | ((void *)0)
| 0-30 | ||||||||||||||||||||||||||||||
| 115 | ) | - | ||||||||||||||||||||||||||||||
| 116 | return never executed: -1;return -1;never executed: return -1; | 0 | ||||||||||||||||||||||||||||||
| 117 | - | |||||||||||||||||||||||||||||||
| 118 | memset(n, '\0', sizeof(*n)); | - | ||||||||||||||||||||||||||||||
| 119 | switch (af) { | - | ||||||||||||||||||||||||||||||
| 120 | case executed 30 times by 1 test: case 2 :Executed by:
executed 30 times by 1 test: case 2 :Executed by:
| 30 | ||||||||||||||||||||||||||||||
| 121 | 2 executed 30 times by 1 test: case 2 :Executed by:
| 30 | ||||||||||||||||||||||||||||||
| 122 | : executed 30 times by 1 test: case 2 :Executed by:
| 30 | ||||||||||||||||||||||||||||||
| 123 | n->af = | - | ||||||||||||||||||||||||||||||
| 124 | 2 | - | ||||||||||||||||||||||||||||||
| 125 | ; | - | ||||||||||||||||||||||||||||||
| 126 | if (l == 0
| 0-30 | ||||||||||||||||||||||||||||||
| 127 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||||||||
| 128 | n->xa.v4.s_addr = | - | ||||||||||||||||||||||||||||||
| 129 | __bswap_32 ( | - | ||||||||||||||||||||||||||||||
| 130 | (0xffffffff << (32 - l)) & 0xffffffff | - | ||||||||||||||||||||||||||||||
| 131 | ) | - | ||||||||||||||||||||||||||||||
| 132 | ; | - | ||||||||||||||||||||||||||||||
| 133 | return executed 30 times by 1 test: 0;return 0;Executed by:
executed 30 times by 1 test: return 0;Executed by:
| 30 | ||||||||||||||||||||||||||||||
| 134 | case never executed: case 10 :never executed: case 10 : | 0 | ||||||||||||||||||||||||||||||
| 135 | 10 never executed: case 10 : | 0 | ||||||||||||||||||||||||||||||
| 136 | : never executed: case 10 : | 0 | ||||||||||||||||||||||||||||||
| 137 | n->af = | - | ||||||||||||||||||||||||||||||
| 138 | 10 | - | ||||||||||||||||||||||||||||||
| 139 | ; | - | ||||||||||||||||||||||||||||||
| 140 | for (i = 0; i < 4
| 0 | ||||||||||||||||||||||||||||||
| 141 | n->xa.addr32[i] = 0xffffffffU; never executed: n->xa.addr32[i] = 0xffffffffU; | 0 | ||||||||||||||||||||||||||||||
| 142 | if (i < 4
| 0 | ||||||||||||||||||||||||||||||
| 143 | n->xa.addr32[i] = never executed: n->xa.addr32[i] = __bswap_32 ( (0xffffffff << (32 - l)) & 0xffffffff ) ; | 0 | ||||||||||||||||||||||||||||||
| 144 | __bswap_32 ( never executed: n->xa.addr32[i] = __bswap_32 ( (0xffffffff << (32 - l)) & 0xffffffff ) ; | 0 | ||||||||||||||||||||||||||||||
| 145 | (0xffffffff << (32 - l)) & 0xffffffff never executed: n->xa.addr32[i] = __bswap_32 ( (0xffffffff << (32 - l)) & 0xffffffff ) ; | 0 | ||||||||||||||||||||||||||||||
| 146 | ) never executed: n->xa.addr32[i] = __bswap_32 ( (0xffffffff << (32 - l)) & 0xffffffff ) ; | 0 | ||||||||||||||||||||||||||||||
| 147 | never executed: n->xa.addr32[i] = __bswap_32 ( (0xffffffff << (32 - l)) & 0xffffffff ) ; | 0 | ||||||||||||||||||||||||||||||
| 148 | ; never executed: n->xa.addr32[i] = __bswap_32 ( (0xffffffff << (32 - l)) & 0xffffffff ) ; | 0 | ||||||||||||||||||||||||||||||
| 149 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||||||||
| 150 | default never executed: :default:never executed: default: | 0 | ||||||||||||||||||||||||||||||
| 151 | return never executed: -1;return -1;never executed: return -1; | 0 | ||||||||||||||||||||||||||||||
| 152 | } | - | ||||||||||||||||||||||||||||||
| 153 | } | - | ||||||||||||||||||||||||||||||
| 154 | - | |||||||||||||||||||||||||||||||
| 155 | - | |||||||||||||||||||||||||||||||
| 156 | - | |||||||||||||||||||||||||||||||
| 157 | - | |||||||||||||||||||||||||||||||
| 158 | - | |||||||||||||||||||||||||||||||
| 159 | static int | - | ||||||||||||||||||||||||||||||
| 160 | addr_and(struct xaddr *dst, const struct xaddr *a, const struct xaddr *b) | - | ||||||||||||||||||||||||||||||
| 161 | { | - | ||||||||||||||||||||||||||||||
| 162 | int i; | - | ||||||||||||||||||||||||||||||
| 163 | - | |||||||||||||||||||||||||||||||
| 164 | if (dst ==
| 0-30 | ||||||||||||||||||||||||||||||
| 165 | ((void *)0)
| 0-30 | ||||||||||||||||||||||||||||||
| 166 | || a ==
| 0-30 | ||||||||||||||||||||||||||||||
| 167 | ((void *)0)
| 0-30 | ||||||||||||||||||||||||||||||
| 168 | || b ==
| 0-30 | ||||||||||||||||||||||||||||||
| 169 | ((void *)0)
| 0-30 | ||||||||||||||||||||||||||||||
| 170 | || a->af != b->af
| 0-30 | ||||||||||||||||||||||||||||||
| 171 | return never executed: -1;return -1;never executed: return -1; | 0 | ||||||||||||||||||||||||||||||
| 172 | - | |||||||||||||||||||||||||||||||
| 173 | memcpy(dst, a, sizeof(*dst)); | - | ||||||||||||||||||||||||||||||
| 174 | switch (a->af) { | - | ||||||||||||||||||||||||||||||
| 175 | case executed 30 times by 1 test: case 2 :Executed by:
executed 30 times by 1 test: case 2 :Executed by:
| 30 | ||||||||||||||||||||||||||||||
| 176 | 2 executed 30 times by 1 test: case 2 :Executed by:
| 30 | ||||||||||||||||||||||||||||||
| 177 | : executed 30 times by 1 test: case 2 :Executed by:
| 30 | ||||||||||||||||||||||||||||||
| 178 | dst->xa.v4.s_addr &= b->xa.v4.s_addr; | - | ||||||||||||||||||||||||||||||
| 179 | return executed 30 times by 1 test: 0;return 0;Executed by:
executed 30 times by 1 test: return 0;Executed by:
| 30 | ||||||||||||||||||||||||||||||
| 180 | case never executed: case 10 :never executed: case 10 : | 0 | ||||||||||||||||||||||||||||||
| 181 | 10 never executed: case 10 : | 0 | ||||||||||||||||||||||||||||||
| 182 | : never executed: case 10 : | 0 | ||||||||||||||||||||||||||||||
| 183 | dst->scope_id = a->scope_id; | - | ||||||||||||||||||||||||||||||
| 184 | for (i = 0; i < 4
| 0 | ||||||||||||||||||||||||||||||
| 185 | dst->xa.addr32[i] &= b->xa.addr32[i]; never executed: dst->xa.addr32[i] &= b->xa.addr32[i]; | 0 | ||||||||||||||||||||||||||||||
| 186 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||||||||
| 187 | default never executed: :default:never executed: default: | 0 | ||||||||||||||||||||||||||||||
| 188 | return never executed: -1;return -1;never executed: return -1; | 0 | ||||||||||||||||||||||||||||||
| 189 | } | - | ||||||||||||||||||||||||||||||
| 190 | } | - | ||||||||||||||||||||||||||||||
| 191 | - | |||||||||||||||||||||||||||||||
| 192 | - | |||||||||||||||||||||||||||||||
| 193 | - | |||||||||||||||||||||||||||||||
| 194 | - | |||||||||||||||||||||||||||||||
| 195 | - | |||||||||||||||||||||||||||||||
| 196 | static int | - | ||||||||||||||||||||||||||||||
| 197 | addr_cmp(const struct xaddr *a, const struct xaddr *b) | - | ||||||||||||||||||||||||||||||
| 198 | { | - | ||||||||||||||||||||||||||||||
| 199 | int i; | - | ||||||||||||||||||||||||||||||
| 200 | - | |||||||||||||||||||||||||||||||
| 201 | if (a->af != b->af
| 0-15 | ||||||||||||||||||||||||||||||
| 202 | return never executed: a->af == return a->af == 10 ? 1 : -1;
never executed: return a->af == 10 ? 1 : -1; | 0 | ||||||||||||||||||||||||||||||
| 203 | 10
never executed: return a->af == 10 ? 1 : -1; | 0 | ||||||||||||||||||||||||||||||
| 204 | ? 1 : -1; never executed: return a->af == 10 ? 1 : -1; | 0 | ||||||||||||||||||||||||||||||
| 205 | - | |||||||||||||||||||||||||||||||
| 206 | switch (a->af) { | - | ||||||||||||||||||||||||||||||
| 207 | case executed 15 times by 1 test: case 2 :Executed by:
executed 15 times by 1 test: case 2 :Executed by:
| 15 | ||||||||||||||||||||||||||||||
| 208 | 2 executed 15 times by 1 test: case 2 :Executed by:
| 15 | ||||||||||||||||||||||||||||||
| 209 | : executed 15 times by 1 test: case 2 :Executed by:
| 15 | ||||||||||||||||||||||||||||||
| 210 | if (a->xa.v4.s_addr == b->xa.v4.s_addr
| 7-8 | ||||||||||||||||||||||||||||||
| 211 | return executed 7 times by 1 test: 0;return 0;Executed by:
executed 7 times by 1 test: return 0;Executed by:
| 7 | ||||||||||||||||||||||||||||||
| 212 | return executed 8 times by 1 test: return __bswap_32 ( a->xa.v4.s_addr ) > __bswap_32 ( b->xa.v4.s_addr ) ? 1 : -1;Executed by:
executed 8 times by 1 test: return __bswap_32 ( a->xa.v4.s_addr ) > __bswap_32 ( b->xa.v4.s_addr ) ? 1 : -1;Executed by:
| 8 | ||||||||||||||||||||||||||||||
| 213 | __bswap_32 (
executed 8 times by 1 test: return __bswap_32 ( a->xa.v4.s_addr ) > __bswap_32 ( b->xa.v4.s_addr ) ? 1 : -1;Executed by:
| 4-8 | ||||||||||||||||||||||||||||||
| 214 | a->xa.v4.s_addr
executed 8 times by 1 test: return __bswap_32 ( a->xa.v4.s_addr ) > __bswap_32 ( b->xa.v4.s_addr ) ? 1 : -1;Executed by:
| 4-8 | ||||||||||||||||||||||||||||||
| 215 | )
executed 8 times by 1 test: return __bswap_32 ( a->xa.v4.s_addr ) > __bswap_32 ( b->xa.v4.s_addr ) ? 1 : -1;Executed by:
| 4-8 | ||||||||||||||||||||||||||||||
| 216 | >
executed 8 times by 1 test: return __bswap_32 ( a->xa.v4.s_addr ) > __bswap_32 ( b->xa.v4.s_addr ) ? 1 : -1;Executed by:
| 4-8 | ||||||||||||||||||||||||||||||
| 217 | __bswap_32 (
executed 8 times by 1 test: return __bswap_32 ( a->xa.v4.s_addr ) > __bswap_32 ( b->xa.v4.s_addr ) ? 1 : -1;Executed by:
| 4-8 | ||||||||||||||||||||||||||||||
| 218 | b->xa.v4.s_addr
executed 8 times by 1 test: return __bswap_32 ( a->xa.v4.s_addr ) > __bswap_32 ( b->xa.v4.s_addr ) ? 1 : -1;Executed by:
| 4-8 | ||||||||||||||||||||||||||||||
| 219 | )
executed 8 times by 1 test: return __bswap_32 ( a->xa.v4.s_addr ) > __bswap_32 ( b->xa.v4.s_addr ) ? 1 : -1;Executed by:
| 4-8 | ||||||||||||||||||||||||||||||
| 220 | ? 1 : -1; executed 8 times by 1 test: return __bswap_32 ( a->xa.v4.s_addr ) > __bswap_32 ( b->xa.v4.s_addr ) ? 1 : -1;Executed by:
| 8 | ||||||||||||||||||||||||||||||
| 221 | case never executed: case 10 :never executed: case 10 : | 0 | ||||||||||||||||||||||||||||||
| 222 | 10 never executed: case 10 : | 0 | ||||||||||||||||||||||||||||||
| 223 | : never executed: case 10 : | 0 | ||||||||||||||||||||||||||||||
| 224 | for (i = 0; i < 16
| 0 | ||||||||||||||||||||||||||||||
| 225 | if (a->xa.addr8[i] - b->xa.addr8[i] != 0
| 0 | ||||||||||||||||||||||||||||||
| 226 | return never executed: a->xa.addr8[i] > b->xa.addr8[i]return a->xa.addr8[i] > b->xa.addr8[i] ? 1 : -1;
never executed: return a->xa.addr8[i] > b->xa.addr8[i] ? 1 : -1; | 0 | ||||||||||||||||||||||||||||||
| 227 | if (a->scope_id == b->scope_id
| 0 | ||||||||||||||||||||||||||||||
| 228 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||||||||
| 229 | return never executed: a->scope_id > b->scope_idreturn a->scope_id > b->scope_id ? 1 : -1;
never executed: return a->scope_id > b->scope_id ? 1 : -1; | 0 | ||||||||||||||||||||||||||||||
| 230 | default never executed: :default:never executed: default: | 0 | ||||||||||||||||||||||||||||||
| 231 | return never executed: -1;return -1;never executed: return -1; | 0 | ||||||||||||||||||||||||||||||
| 232 | } | - | ||||||||||||||||||||||||||||||
| 233 | } | - | ||||||||||||||||||||||||||||||
| 234 | - | |||||||||||||||||||||||||||||||
| 235 | - | |||||||||||||||||||||||||||||||
| 236 | - | |||||||||||||||||||||||||||||||
| 237 | - | |||||||||||||||||||||||||||||||
| 238 | - | |||||||||||||||||||||||||||||||
| 239 | static int | - | ||||||||||||||||||||||||||||||
| 240 | addr_pton(const char *p, struct xaddr *n) | - | ||||||||||||||||||||||||||||||
| 241 | { | - | ||||||||||||||||||||||||||||||
| 242 | struct addrinfo hints, *ai = | - | ||||||||||||||||||||||||||||||
| 243 | ((void *)0) | - | ||||||||||||||||||||||||||||||
| 244 | ; | - | ||||||||||||||||||||||||||||||
| 245 | int ret = -1; | - | ||||||||||||||||||||||||||||||
| 246 | - | |||||||||||||||||||||||||||||||
| 247 | memset(&hints, '\0', sizeof(hints)); | - | ||||||||||||||||||||||||||||||
| 248 | hints.ai_flags = | - | ||||||||||||||||||||||||||||||
| 249 | 0x0004 | - | ||||||||||||||||||||||||||||||
| 250 | ; | - | ||||||||||||||||||||||||||||||
| 251 | - | |||||||||||||||||||||||||||||||
| 252 | if (p ==
| 0-34 | ||||||||||||||||||||||||||||||
| 253 | ((void *)0)
| 0-34 | ||||||||||||||||||||||||||||||
| 254 | || getaddrinfo(p,
| 3-31 | ||||||||||||||||||||||||||||||
| 255 | ((void *)0)
| 3-31 | ||||||||||||||||||||||||||||||
| 256 | , &hints, &ai) != 0
| 3-31 | ||||||||||||||||||||||||||||||
| 257 | goto executed 3 times by 1 test: out;goto out;Executed by:
executed 3 times by 1 test: goto out;Executed by:
| 3 | ||||||||||||||||||||||||||||||
| 258 | if (ai ==
| 0-31 | ||||||||||||||||||||||||||||||
| 259 | ((void *)0)
| 0-31 | ||||||||||||||||||||||||||||||
| 260 | || ai->ai_addr ==
| 0-31 | ||||||||||||||||||||||||||||||
| 261 | ((void *)0)
| 0-31 | ||||||||||||||||||||||||||||||
| 262 | ) | - | ||||||||||||||||||||||||||||||
| 263 | goto never executed: out;goto out;never executed: goto out; | 0 | ||||||||||||||||||||||||||||||
| 264 | if (n !=
| 0-31 | ||||||||||||||||||||||||||||||
| 265 | ((void *)0)
| 0-31 | ||||||||||||||||||||||||||||||
| 266 | && addr_sa_to_xaddr(ai->ai_addr, ai->ai_addrlen, n) == -1
| 0-31 | ||||||||||||||||||||||||||||||
| 267 | goto never executed: out;goto out;never executed: goto out; | 0 | ||||||||||||||||||||||||||||||
| 268 | - | |||||||||||||||||||||||||||||||
| 269 | ret = 0; | - | ||||||||||||||||||||||||||||||
| 270 | out: code before this statement executed 31 times by 1 test: out:Executed by:
| 31 | ||||||||||||||||||||||||||||||
| 271 | if (ai !=
| 3-31 | ||||||||||||||||||||||||||||||
| 272 | ((void *)0)
| 3-31 | ||||||||||||||||||||||||||||||
| 273 | ) | - | ||||||||||||||||||||||||||||||
| 274 | freeaddrinfo(ai); executed 31 times by 1 test: freeaddrinfo(ai);Executed by:
| 31 | ||||||||||||||||||||||||||||||
| 275 | return executed 34 times by 1 test: ret;return ret;Executed by:
executed 34 times by 1 test: return ret;Executed by:
| 34 | ||||||||||||||||||||||||||||||
| 276 | } | - | ||||||||||||||||||||||||||||||
| 277 | - | |||||||||||||||||||||||||||||||
| 278 | - | |||||||||||||||||||||||||||||||
| 279 | - | |||||||||||||||||||||||||||||||
| 280 | - | |||||||||||||||||||||||||||||||
| 281 | - | |||||||||||||||||||||||||||||||
| 282 | static int | - | ||||||||||||||||||||||||||||||
| 283 | addr_invert(struct xaddr *n) | - | ||||||||||||||||||||||||||||||
| 284 | { | - | ||||||||||||||||||||||||||||||
| 285 | int i; | - | ||||||||||||||||||||||||||||||
| 286 | - | |||||||||||||||||||||||||||||||
| 287 | if (n ==
| 0-15 | ||||||||||||||||||||||||||||||
| 288 | ((void *)0)
| 0-15 | ||||||||||||||||||||||||||||||
| 289 | ) | - | ||||||||||||||||||||||||||||||
| 290 | return never executed: (-1);return (-1);never executed: return (-1); | 0 | ||||||||||||||||||||||||||||||
| 291 | - | |||||||||||||||||||||||||||||||
| 292 | switch (n->af) { | - | ||||||||||||||||||||||||||||||
| 293 | case executed 15 times by 1 test: case 2 :Executed by:
executed 15 times by 1 test: case 2 :Executed by:
| 15 | ||||||||||||||||||||||||||||||
| 294 | 2 executed 15 times by 1 test: case 2 :Executed by:
| 15 | ||||||||||||||||||||||||||||||
| 295 | : executed 15 times by 1 test: case 2 :Executed by:
| 15 | ||||||||||||||||||||||||||||||
| 296 | n->xa.v4.s_addr = ~n->xa.v4.s_addr; | - | ||||||||||||||||||||||||||||||
| 297 | return executed 15 times by 1 test: (0);return (0);Executed by:
executed 15 times by 1 test: return (0);Executed by:
| 15 | ||||||||||||||||||||||||||||||
| 298 | case never executed: case 10 :never executed: case 10 : | 0 | ||||||||||||||||||||||||||||||
| 299 | 10 never executed: case 10 : | 0 | ||||||||||||||||||||||||||||||
| 300 | : never executed: case 10 : | 0 | ||||||||||||||||||||||||||||||
| 301 | for (i = 0; i < 4
| 0 | ||||||||||||||||||||||||||||||
| 302 | n->xa.addr32[i] = ~n->xa.addr32[i]; never executed: n->xa.addr32[i] = ~n->xa.addr32[i]; | 0 | ||||||||||||||||||||||||||||||
| 303 | return never executed: (0);return (0);never executed: return (0); | 0 | ||||||||||||||||||||||||||||||
| 304 | default never executed: :default:never executed: default: | 0 | ||||||||||||||||||||||||||||||
| 305 | return never executed: (-1);return (-1);never executed: return (-1); | 0 | ||||||||||||||||||||||||||||||
| 306 | } | - | ||||||||||||||||||||||||||||||
| 307 | } | - | ||||||||||||||||||||||||||||||
| 308 | - | |||||||||||||||||||||||||||||||
| 309 | - | |||||||||||||||||||||||||||||||
| 310 | - | |||||||||||||||||||||||||||||||
| 311 | - | |||||||||||||||||||||||||||||||
| 312 | - | |||||||||||||||||||||||||||||||
| 313 | - | |||||||||||||||||||||||||||||||
| 314 | static int | - | ||||||||||||||||||||||||||||||
| 315 | addr_hostmask(int af, u_int l, struct xaddr *n) | - | ||||||||||||||||||||||||||||||
| 316 | { | - | ||||||||||||||||||||||||||||||
| 317 | if (addr_netmask(af, l, n) == -1
| 0-15 | ||||||||||||||||||||||||||||||
| 318 | return never executed: (-1);return (-1);never executed: return (-1); | 0 | ||||||||||||||||||||||||||||||
| 319 | return executed 15 times by 1 test: (0);return (0);Executed by:
executed 15 times by 1 test: return (0);Executed by:
| 15 | ||||||||||||||||||||||||||||||
| 320 | } | - | ||||||||||||||||||||||||||||||
| 321 | - | |||||||||||||||||||||||||||||||
| 322 | - | |||||||||||||||||||||||||||||||
| 323 | - | |||||||||||||||||||||||||||||||
| 324 | - | |||||||||||||||||||||||||||||||
| 325 | - | |||||||||||||||||||||||||||||||
| 326 | static int | - | ||||||||||||||||||||||||||||||
| 327 | addr_is_all0s(const struct xaddr *a) | - | ||||||||||||||||||||||||||||||
| 328 | { | - | ||||||||||||||||||||||||||||||
| 329 | int i; | - | ||||||||||||||||||||||||||||||
| 330 | - | |||||||||||||||||||||||||||||||
| 331 | switch (a->af) { | - | ||||||||||||||||||||||||||||||
| 332 | case executed 15 times by 1 test: case 2 :Executed by:
executed 15 times by 1 test: case 2 :Executed by:
| 15 | ||||||||||||||||||||||||||||||
| 333 | 2 executed 15 times by 1 test: case 2 :Executed by:
| 15 | ||||||||||||||||||||||||||||||
| 334 | : executed 15 times by 1 test: case 2 :Executed by:
| 15 | ||||||||||||||||||||||||||||||
| 335 | return executed 15 times by 1 test: (a->xa.v4.s_addr == 0return (a->xa.v4.s_addr == 0 ? 0 : -1);Executed by:
executed 15 times by 1 test: return (a->xa.v4.s_addr == 0 ? 0 : -1);Executed by:
| 0-15 | ||||||||||||||||||||||||||||||
| 336 | case never executed: case 10 :never executed: case 10 : | 0 | ||||||||||||||||||||||||||||||
| 337 | 10 never executed: case 10 : | 0 | ||||||||||||||||||||||||||||||
| 338 | : never executed: ;case 10 : | 0 | ||||||||||||||||||||||||||||||
| 339 | for (i = 0; i < 4
| 0 | ||||||||||||||||||||||||||||||
| 340 | if (a->xa.addr32[i] != 0
| 0 | ||||||||||||||||||||||||||||||
| 341 | return never executed: (-1);return (-1);never executed: return (-1); | 0 | ||||||||||||||||||||||||||||||
| 342 | return never executed: (0);return (0);never executed: return (0); | 0 | ||||||||||||||||||||||||||||||
| 343 | default never executed: :default:never executed: default: | 0 | ||||||||||||||||||||||||||||||
| 344 | return never executed: (-1);return (-1);never executed: return (-1); | 0 | ||||||||||||||||||||||||||||||
| 345 | } | - | ||||||||||||||||||||||||||||||
| 346 | } | - | ||||||||||||||||||||||||||||||
| 347 | - | |||||||||||||||||||||||||||||||
| 348 | - | |||||||||||||||||||||||||||||||
| 349 | - | |||||||||||||||||||||||||||||||
| 350 | - | |||||||||||||||||||||||||||||||
| 351 | - | |||||||||||||||||||||||||||||||
| 352 | - | |||||||||||||||||||||||||||||||
| 353 | - | |||||||||||||||||||||||||||||||
| 354 | static int | - | ||||||||||||||||||||||||||||||
| 355 | addr_host_is_all0s(const struct xaddr *a, u_int masklen) | - | ||||||||||||||||||||||||||||||
| 356 | { | - | ||||||||||||||||||||||||||||||
| 357 | struct xaddr tmp_addr, tmp_mask, tmp_result; | - | ||||||||||||||||||||||||||||||
| 358 | - | |||||||||||||||||||||||||||||||
| 359 | memcpy(&tmp_addr, a, sizeof(tmp_addr)); | - | ||||||||||||||||||||||||||||||
| 360 | if (addr_hostmask(a->af, masklen, &tmp_mask) == -1
| 0-15 | ||||||||||||||||||||||||||||||
| 361 | return never executed: (-1);return (-1);never executed: return (-1); | 0 | ||||||||||||||||||||||||||||||
| 362 | if (addr_and(&tmp_result, &tmp_addr, &tmp_mask) == -1
| 0-15 | ||||||||||||||||||||||||||||||
| 363 | return never executed: (-1);return (-1);never executed: return (-1); | 0 | ||||||||||||||||||||||||||||||
| 364 | return executed 15 times by 1 test: (addr_is_all0s(&tmp_result));return (addr_is_all0s(&tmp_result));Executed by:
executed 15 times by 1 test: return (addr_is_all0s(&tmp_result));Executed by:
| 15 | ||||||||||||||||||||||||||||||
| 365 | } | - | ||||||||||||||||||||||||||||||
| 366 | - | |||||||||||||||||||||||||||||||
| 367 | - | |||||||||||||||||||||||||||||||
| 368 | - | |||||||||||||||||||||||||||||||
| 369 | - | |||||||||||||||||||||||||||||||
| 370 | - | |||||||||||||||||||||||||||||||
| 371 | static int | - | ||||||||||||||||||||||||||||||
| 372 | addr_pton_cidr(const char *p, struct xaddr *n, u_int *l) | - | ||||||||||||||||||||||||||||||
| 373 | { | - | ||||||||||||||||||||||||||||||
| 374 | struct xaddr tmp; | - | ||||||||||||||||||||||||||||||
| 375 | long unsigned int masklen = 999; | - | ||||||||||||||||||||||||||||||
| 376 | char addrbuf[64], *mp, *cp; | - | ||||||||||||||||||||||||||||||
| 377 | - | |||||||||||||||||||||||||||||||
| 378 | - | |||||||||||||||||||||||||||||||
| 379 | if (p ==
| 0-19 | ||||||||||||||||||||||||||||||
| 380 | ((void *)0)
| 0-19 | ||||||||||||||||||||||||||||||
| 381 | || strlcpy(addrbuf, p, sizeof(addrbuf)) >= sizeof(addrbuf)
| 0-19 | ||||||||||||||||||||||||||||||
| 382 | return never executed: -1;return -1;never executed: return -1; | 0 | ||||||||||||||||||||||||||||||
| 383 | - | |||||||||||||||||||||||||||||||
| 384 | if ((
| 7-12 | ||||||||||||||||||||||||||||||
| 385 | (__extension__ (__builtin_constant_p (
| 0-19 | ||||||||||||||||||||||||||||||
| 386 | '/'
| 0-19 | ||||||||||||||||||||||||||||||
| 387 | )
| 0-19 | ||||||||||||||||||||||||||||||
| 388 | addrbuf
| 0-19 | ||||||||||||||||||||||||||||||
| 389 | )
| 0-19 | ||||||||||||||||||||||||||||||
| 390 | '/'
| 0-19 | ||||||||||||||||||||||||||||||
| 391 | ) == '\0'
| 0-19 | ||||||||||||||||||||||||||||||
| 392 | addrbuf
| 7-12 | ||||||||||||||||||||||||||||||
| 393 | ,
| 7-12 | ||||||||||||||||||||||||||||||
| 394 | '/'
| 7-12 | ||||||||||||||||||||||||||||||
| 395 | ) : __builtin_strchr (
| 7-12 | ||||||||||||||||||||||||||||||
| 396 | addrbuf
| 7-12 | ||||||||||||||||||||||||||||||
| 397 | ,
| 7-12 | ||||||||||||||||||||||||||||||
| 398 | '/'
| 7-12 | ||||||||||||||||||||||||||||||
| 399 | )))
| 7-12 | ||||||||||||||||||||||||||||||
| 400 | ) !=
| 7-12 | ||||||||||||||||||||||||||||||
| 401 | ((void *)0)
| 7-12 | ||||||||||||||||||||||||||||||
| 402 | ) { | - | ||||||||||||||||||||||||||||||
| 403 | *mp = '\0'; | - | ||||||||||||||||||||||||||||||
| 404 | mp++; | - | ||||||||||||||||||||||||||||||
| 405 | masklen = strtoul(mp, &cp, 10); | - | ||||||||||||||||||||||||||||||
| 406 | if (*
| 0-7 | ||||||||||||||||||||||||||||||
| 407 | return never executed: -1;return -1;never executed: return -1; | 0 | ||||||||||||||||||||||||||||||
| 408 | } executed 7 times by 1 test: end of blockExecuted by:
| 7 | ||||||||||||||||||||||||||||||
| 409 | - | |||||||||||||||||||||||||||||||
| 410 | if (addr_pton(addrbuf, &tmp) == -1
| 2-17 | ||||||||||||||||||||||||||||||
| 411 | return executed 2 times by 1 test: -1;return -1;Executed by:
executed 2 times by 1 test: return -1;Executed by:
| 2 | ||||||||||||||||||||||||||||||
| 412 | - | |||||||||||||||||||||||||||||||
| 413 | if (mp ==
| 7-10 | ||||||||||||||||||||||||||||||
| 414 | ((void *)0)
| 7-10 | ||||||||||||||||||||||||||||||
| 415 | ) | - | ||||||||||||||||||||||||||||||
| 416 | masklen = addr_unicast_masklen(tmp.af); executed 10 times by 1 test: masklen = addr_unicast_masklen(tmp.af);Executed by:
| 10 | ||||||||||||||||||||||||||||||
| 417 | if (masklen_valid(tmp.af, masklen) == -1
| 2-15 | ||||||||||||||||||||||||||||||
| 418 | return executed 2 times by 1 test: -2;return -2;Executed by:
executed 2 times by 1 test: return -2;Executed by:
| 2 | ||||||||||||||||||||||||||||||
| 419 | if (addr_host_is_all0s(&tmp, masklen) != 0
| 0-15 | ||||||||||||||||||||||||||||||
| 420 | return never executed: -2;return -2;never executed: return -2; | 0 | ||||||||||||||||||||||||||||||
| 421 | - | |||||||||||||||||||||||||||||||
| 422 | if (n !=
| 0-15 | ||||||||||||||||||||||||||||||
| 423 | ((void *)0)
| 0-15 | ||||||||||||||||||||||||||||||
| 424 | ) | - | ||||||||||||||||||||||||||||||
| 425 | memcpy(n, &tmp, sizeof(*n)); executed 15 times by 1 test: memcpy(n, &tmp, sizeof(*n));Executed by:
| 15 | ||||||||||||||||||||||||||||||
| 426 | if (l !=
| 0-15 | ||||||||||||||||||||||||||||||
| 427 | ((void *)0)
| 0-15 | ||||||||||||||||||||||||||||||
| 428 | ) | - | ||||||||||||||||||||||||||||||
| 429 | * executed 15 times by 1 test: l = masklen;*l = masklen;Executed by:
executed 15 times by 1 test: *l = masklen;Executed by:
| 15 | ||||||||||||||||||||||||||||||
| 430 | - | |||||||||||||||||||||||||||||||
| 431 | return executed 15 times by 1 test: 0;return 0;Executed by:
executed 15 times by 1 test: return 0;Executed by:
| 15 | ||||||||||||||||||||||||||||||
| 432 | } | - | ||||||||||||||||||||||||||||||
| 433 | - | |||||||||||||||||||||||||||||||
| 434 | static int | - | ||||||||||||||||||||||||||||||
| 435 | addr_netmatch(const struct xaddr *host, const struct xaddr *net, u_int masklen) | - | ||||||||||||||||||||||||||||||
| 436 | { | - | ||||||||||||||||||||||||||||||
| 437 | struct xaddr tmp_mask, tmp_result; | - | ||||||||||||||||||||||||||||||
| 438 | - | |||||||||||||||||||||||||||||||
| 439 | if (host->af != net->af
| 0-15 | ||||||||||||||||||||||||||||||
| 440 | return never executed: -1;return -1;never executed: return -1; | 0 | ||||||||||||||||||||||||||||||
| 441 | - | |||||||||||||||||||||||||||||||
| 442 | if (addr_netmask(host->af, masklen, &tmp_mask) == -1
| 0-15 | ||||||||||||||||||||||||||||||
| 443 | return never executed: -1;return -1;never executed: return -1; | 0 | ||||||||||||||||||||||||||||||
| 444 | if (addr_and(&tmp_result, host, &tmp_mask) == -1
| 0-15 | ||||||||||||||||||||||||||||||
| 445 | return never executed: -1;return -1;never executed: return -1; | 0 | ||||||||||||||||||||||||||||||
| 446 | return executed 15 times by 1 test: addr_cmp(&tmp_result, net);return addr_cmp(&tmp_result, net);Executed by:
executed 15 times by 1 test: return addr_cmp(&tmp_result, net);Executed by:
| 15 | ||||||||||||||||||||||||||||||
| 447 | } | - | ||||||||||||||||||||||||||||||
| 448 | int | - | ||||||||||||||||||||||||||||||
| 449 | addr_match_list(const char *addr, const char *_list) | - | ||||||||||||||||||||||||||||||
| 450 | { | - | ||||||||||||||||||||||||||||||
| 451 | char *list, *cp, *o; | - | ||||||||||||||||||||||||||||||
| 452 | struct xaddr try_addr, match_addr; | - | ||||||||||||||||||||||||||||||
| 453 | u_int masklen, neg; | - | ||||||||||||||||||||||||||||||
| 454 | int ret = 0, r; | - | ||||||||||||||||||||||||||||||
| 455 | - | |||||||||||||||||||||||||||||||
| 456 | if (addr !=
| 2-15 | ||||||||||||||||||||||||||||||
| 457 | ((void *)0)
| 2-15 | ||||||||||||||||||||||||||||||
| 458 | && addr_pton(addr, &try_addr) != 0
| 1-14 | ||||||||||||||||||||||||||||||
| 459 | debug2("%s: couldn't parse address %.100s", __func__, addr); | - | ||||||||||||||||||||||||||||||
| 460 | return executed 1 time by 1 test: 0;return 0;Executed by:
executed 1 time by 1 test: return 0;Executed by:
| 1 | ||||||||||||||||||||||||||||||
| 461 | } | - | ||||||||||||||||||||||||||||||
| 462 | if ((
| 0-16 | ||||||||||||||||||||||||||||||
| 463 | (__extension__ (__builtin_constant_p (
| 0-16 | ||||||||||||||||||||||||||||||
| 464 | _list
| 0-16 | ||||||||||||||||||||||||||||||
| 465 | )
| 0-16 | ||||||||||||||||||||||||||||||
| 466 | _list
| 0-16 | ||||||||||||||||||||||||||||||
| 467 | ) + 1) - (size_t)(const void *)(
| 0-16 | ||||||||||||||||||||||||||||||
| 468 | _list
| 0-16 | ||||||||||||||||||||||||||||||
| 469 | ) == 1)
| 0-16 | ||||||||||||||||||||||||||||||
| 470 | _list
| 0-16 | ||||||||||||||||||||||||||||||
| 471 | ))[0] == '\0'
| 0-16 | ||||||||||||||||||||||||||||||
| 472 | _list
| 0-16 | ||||||||||||||||||||||||||||||
| 473 | ) + 1; char *__retval = (char *) malloc (__len); if (__retval != ((void *)0)
never executed: __retval = (char *) memcpy (__retval, _list , __len);
| 0-16 | ||||||||||||||||||||||||||||||
| 474 | _list
never executed: __retval = (char *) memcpy (__retval, _list , __len); | 0-16 | ||||||||||||||||||||||||||||||
| 475 | , __len);
never executed: __retval; })) : __strdup (__retval = (char *) memcpy (__retval, _list , __len);
| 0-16 | ||||||||||||||||||||||||||||||
| 476 | _list
| 0-16 | ||||||||||||||||||||||||||||||
| 477 | )))
| 0-16 | ||||||||||||||||||||||||||||||
| 478 | ) ==
| 0-16 | ||||||||||||||||||||||||||||||
| 479 | ((void *)0)
| 0-16 | ||||||||||||||||||||||||||||||
| 480 | ) | - | ||||||||||||||||||||||||||||||
| 481 | return never executed: -1;return -1;never executed: return -1; | 0 | ||||||||||||||||||||||||||||||
| 482 | while ((
| 10-19 | ||||||||||||||||||||||||||||||
| 483 | __extension__ ({ char __r0, __r1, __r2; (__builtin_constant_p (
| 10-19 | ||||||||||||||||||||||||||||||
| 484 | ","
| 10-19 | ||||||||||||||||||||||||||||||
| 485 | ) && ((size_t)(const void *)((
| 10-19 | ||||||||||||||||||||||||||||||
| 486 | ","
| 10-19 | ||||||||||||||||||||||||||||||
| 487 | ) + 1) - (size_t)(const void *)(
| 10-19 | ||||||||||||||||||||||||||||||
| 488 | ","
| 10-19 | ||||||||||||||||||||||||||||||
| 489 | ) == 1) && (__r0 = ((const char *) (
| 10-19 | ||||||||||||||||||||||||||||||
| 490 | ","
| 10-19 | ||||||||||||||||||||||||||||||
| 491 | ))[0], ((const char *) (
| 10-19 | ||||||||||||||||||||||||||||||
| 492 | ","
| 10-19 | ||||||||||||||||||||||||||||||
| 493 | ))[0] != '\0') ? ((__r1 = ((const char *) (
| 10-19 | ||||||||||||||||||||||||||||||
| 494 | ","
| 10-19 | ||||||||||||||||||||||||||||||
| 495 | ))[1], ((const char *) (
| 10-19 | ||||||||||||||||||||||||||||||
| 496 | ","
| 10-19 | ||||||||||||||||||||||||||||||
| 497 | ))[1] == '\0') ? __strsep_1c (
| 10-19 | ||||||||||||||||||||||||||||||
| 498 | &list
| 10-19 | ||||||||||||||||||||||||||||||
| 499 | , __r0) : ((__r2 = ((const char *) (
| 10-19 | ||||||||||||||||||||||||||||||
| 500 | ","
| 10-19 | ||||||||||||||||||||||||||||||
| 501 | ))[2], __r2 == '\0') ? __strsep_2c (
| 10-19 | ||||||||||||||||||||||||||||||
| 502 | &list
| 10-19 | ||||||||||||||||||||||||||||||
| 503 | , __r0, __r1) : (((const char *) (
| 10-19 | ||||||||||||||||||||||||||||||
| 504 | ","
| 10-19 | ||||||||||||||||||||||||||||||
| 505 | ))[3] == '\0' ? __strsep_3c (
| 10-19 | ||||||||||||||||||||||||||||||
| 506 | &list
| 10-19 | ||||||||||||||||||||||||||||||
| 507 | , __r0, __r1, __r2) : __strsep_g (
| 10-19 | ||||||||||||||||||||||||||||||
| 508 | &list
| 10-19 | ||||||||||||||||||||||||||||||
| 509 | ,
| 10-19 | ||||||||||||||||||||||||||||||
| 510 | ","
| 10-19 | ||||||||||||||||||||||||||||||
| 511 | )))) : __strsep_g (
| 10-19 | ||||||||||||||||||||||||||||||
| 512 | &list
| 10-19 | ||||||||||||||||||||||||||||||
| 513 | ,
| 10-19 | ||||||||||||||||||||||||||||||
| 514 | ","
| 10-19 | ||||||||||||||||||||||||||||||
| 515 | )); })
| 10-19 | ||||||||||||||||||||||||||||||
| 516 | ) !=
| 10-19 | ||||||||||||||||||||||||||||||
| 517 | ((void *)0)
| 10-19 | ||||||||||||||||||||||||||||||
| 518 | ) { | - | ||||||||||||||||||||||||||||||
| 519 | neg = *cp == '!'; | - | ||||||||||||||||||||||||||||||
| 520 | if (neg
| 4-15 | ||||||||||||||||||||||||||||||
| 521 | cp++; executed 4 times by 1 test: cp++;Executed by:
| 4 | ||||||||||||||||||||||||||||||
| 522 | if (*
| 0-19 | ||||||||||||||||||||||||||||||
| 523 | ret = -2; | - | ||||||||||||||||||||||||||||||
| 524 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||
| 525 | } | - | ||||||||||||||||||||||||||||||
| 526 | - | |||||||||||||||||||||||||||||||
| 527 | r = addr_pton_cidr(cp, &match_addr, &masklen); | - | ||||||||||||||||||||||||||||||
| 528 | if (r == -2
| 2-17 | ||||||||||||||||||||||||||||||
| 529 | debug2("%s: inconsistent mask length for " | - | ||||||||||||||||||||||||||||||
| 530 | "match network \"%.100s\"", __func__, cp); | - | ||||||||||||||||||||||||||||||
| 531 | ret = -2; | - | ||||||||||||||||||||||||||||||
| 532 | break; executed 2 times by 1 test: break;Executed by:
| 2 | ||||||||||||||||||||||||||||||
| 533 | } else if (r == 0
| 2-15 | ||||||||||||||||||||||||||||||
| 534 | if (addr !=
| 0-15 | ||||||||||||||||||||||||||||||
| 535 | ((void *)0)
| 0-15 | ||||||||||||||||||||||||||||||
| 536 | && addr_netmatch(&try_addr,
| 7-8 | ||||||||||||||||||||||||||||||
| 537 | &match_addr, masklen) == 0
| 7-8 | ||||||||||||||||||||||||||||||
| 538 | foundit: | - | ||||||||||||||||||||||||||||||
| 539 | if (neg
| 4 | ||||||||||||||||||||||||||||||
| 540 | ret = -1; | - | ||||||||||||||||||||||||||||||
| 541 | break; executed 4 times by 1 test: break;Executed by:
| 4 | ||||||||||||||||||||||||||||||
| 542 | } | - | ||||||||||||||||||||||||||||||
| 543 | ret = 1; | - | ||||||||||||||||||||||||||||||
| 544 | } executed 4 times by 1 test: end of blockExecuted by:
| 4 | ||||||||||||||||||||||||||||||
| 545 | continue; executed 12 times by 1 test: continue;Executed by:
| 12 | ||||||||||||||||||||||||||||||
| 546 | } else { | - | ||||||||||||||||||||||||||||||
| 547 | - | |||||||||||||||||||||||||||||||
| 548 | if (addr !=
| 1 | ||||||||||||||||||||||||||||||
| 549 | ((void *)0)
| 1 | ||||||||||||||||||||||||||||||
| 550 | && match_pattern(addr, cp) == 1
| 0-1 | ||||||||||||||||||||||||||||||
| 551 | goto executed 1 time by 1 test: foundit;goto foundit;Executed by:
executed 1 time by 1 test: goto foundit;Executed by:
| 1 | ||||||||||||||||||||||||||||||
| 552 | } executed 1 time by 1 test: end of blockExecuted by:
| 1 | ||||||||||||||||||||||||||||||
| 553 | } | - | ||||||||||||||||||||||||||||||
| 554 | free(o); | - | ||||||||||||||||||||||||||||||
| 555 | - | |||||||||||||||||||||||||||||||
| 556 | return executed 16 times by 1 test: ret;return ret;Executed by:
executed 16 times by 1 test: return ret;Executed by:
| 16 | ||||||||||||||||||||||||||||||
| 557 | } | - | ||||||||||||||||||||||||||||||
| 558 | int | - | ||||||||||||||||||||||||||||||
| 559 | addr_match_cidr_list(const char *addr, const char *_list) | - | ||||||||||||||||||||||||||||||
| 560 | { | - | ||||||||||||||||||||||||||||||
| 561 | char *list, *cp, *o; | - | ||||||||||||||||||||||||||||||
| 562 | struct xaddr try_addr, match_addr; | - | ||||||||||||||||||||||||||||||
| 563 | u_int masklen; | - | ||||||||||||||||||||||||||||||
| 564 | int ret = 0, r; | - | ||||||||||||||||||||||||||||||
| 565 | - | |||||||||||||||||||||||||||||||
| 566 | if (addr !=
| 0 | ||||||||||||||||||||||||||||||
| 567 | ((void *)0)
| 0 | ||||||||||||||||||||||||||||||
| 568 | && addr_pton(addr, &try_addr) != 0
| 0 | ||||||||||||||||||||||||||||||
| 569 | debug2("%s: couldn't parse address %.100s", __func__, addr); | - | ||||||||||||||||||||||||||||||
| 570 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||||||||
| 571 | } | - | ||||||||||||||||||||||||||||||
| 572 | if ((
| 0 | ||||||||||||||||||||||||||||||
| 573 | (__extension__ (__builtin_constant_p (
| 0 | ||||||||||||||||||||||||||||||
| 574 | _list
| 0 | ||||||||||||||||||||||||||||||
| 575 | )
| 0 | ||||||||||||||||||||||||||||||
| 576 | _list
| 0 | ||||||||||||||||||||||||||||||
| 577 | ) + 1) - (size_t)(const void *)(
| 0 | ||||||||||||||||||||||||||||||
| 578 | _list
| 0 | ||||||||||||||||||||||||||||||
| 579 | ) == 1)
| 0 | ||||||||||||||||||||||||||||||
| 580 | _list
| 0 | ||||||||||||||||||||||||||||||
| 581 | ))[0] == '\0'
| 0 | ||||||||||||||||||||||||||||||
| 582 | _list
| 0 | ||||||||||||||||||||||||||||||
| 583 | ) + 1; char *__retval = (char *) malloc (__len); if (__retval != ((void *)0)
never executed: __retval = (char *) memcpy (__retval, _list , __len); | 0 | ||||||||||||||||||||||||||||||
| 584 | _list
never executed: __retval = (char *) memcpy (__retval, _list , __len); | 0 | ||||||||||||||||||||||||||||||
| 585 | , __len); __retval; })) : __strdup (
| 0 | ||||||||||||||||||||||||||||||
| 586 | _list
| 0 | ||||||||||||||||||||||||||||||
| 587 | )))
| 0 | ||||||||||||||||||||||||||||||
| 588 | ) ==
| 0 | ||||||||||||||||||||||||||||||
| 589 | ((void *)0)
| 0 | ||||||||||||||||||||||||||||||
| 590 | ) | - | ||||||||||||||||||||||||||||||
| 591 | return never executed: -1;return -1;never executed: return -1; | 0 | ||||||||||||||||||||||||||||||
| 592 | while ((
| 0 | ||||||||||||||||||||||||||||||
| 593 | __extension__ ({ char __r0, __r1, __r2; (__builtin_constant_p (
| 0 | ||||||||||||||||||||||||||||||
| 594 | ","
| 0 | ||||||||||||||||||||||||||||||
| 595 | ) && ((size_t)(const void *)((
| 0 | ||||||||||||||||||||||||||||||
| 596 | ","
| 0 | ||||||||||||||||||||||||||||||
| 597 | ) + 1) - (size_t)(const void *)(
| 0 | ||||||||||||||||||||||||||||||
| 598 | ","
| 0 | ||||||||||||||||||||||||||||||
| 599 | ) == 1) && (__r0 = ((const char *) (
| 0 | ||||||||||||||||||||||||||||||
| 600 | ","
| 0 | ||||||||||||||||||||||||||||||
| 601 | ))[0], ((const char *) (
| 0 | ||||||||||||||||||||||||||||||
| 602 | ","
| 0 | ||||||||||||||||||||||||||||||
| 603 | ))[0] != '\0') ? ((__r1 = ((const char *) (
| 0 | ||||||||||||||||||||||||||||||
| 604 | ","
| 0 | ||||||||||||||||||||||||||||||
| 605 | ))[1], ((const char *) (
| 0 | ||||||||||||||||||||||||||||||
| 606 | ","
| 0 | ||||||||||||||||||||||||||||||
| 607 | ))[1] == '\0') ? __strsep_1c (
| 0 | ||||||||||||||||||||||||||||||
| 608 | &list
| 0 | ||||||||||||||||||||||||||||||
| 609 | , __r0) : ((__r2 = ((const char *) (
| 0 | ||||||||||||||||||||||||||||||
| 610 | ","
| 0 | ||||||||||||||||||||||||||||||
| 611 | ))[2], __r2 == '\0') ? __strsep_2c (
| 0 | ||||||||||||||||||||||||||||||
| 612 | &list
| 0 | ||||||||||||||||||||||||||||||
| 613 | , __r0, __r1) : (((const char *) (
| 0 | ||||||||||||||||||||||||||||||
| 614 | ","
| 0 | ||||||||||||||||||||||||||||||
| 615 | ))[3] == '\0' ? __strsep_3c (
| 0 | ||||||||||||||||||||||||||||||
| 616 | &list
| 0 | ||||||||||||||||||||||||||||||
| 617 | , __r0, __r1, __r2) : __strsep_g (
| 0 | ||||||||||||||||||||||||||||||
| 618 | &list
| 0 | ||||||||||||||||||||||||||||||
| 619 | ,
| 0 | ||||||||||||||||||||||||||||||
| 620 | ","
| 0 | ||||||||||||||||||||||||||||||
| 621 | )))) : __strsep_g (
| 0 | ||||||||||||||||||||||||||||||
| 622 | &list
| 0 | ||||||||||||||||||||||||||||||
| 623 | ,
| 0 | ||||||||||||||||||||||||||||||
| 624 | ","
| 0 | ||||||||||||||||||||||||||||||
| 625 | )); })
| 0 | ||||||||||||||||||||||||||||||
| 626 | ) !=
| 0 | ||||||||||||||||||||||||||||||
| 627 | ((void *)0)
| 0 | ||||||||||||||||||||||||||||||
| 628 | ) { | - | ||||||||||||||||||||||||||||||
| 629 | if (*
| 0 | ||||||||||||||||||||||||||||||
| 630 | error("%s: empty entry in list \"%.100s\"", | - | ||||||||||||||||||||||||||||||
| 631 | __func__, o); | - | ||||||||||||||||||||||||||||||
| 632 | ret = -1; | - | ||||||||||||||||||||||||||||||
| 633 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||
| 634 | } | - | ||||||||||||||||||||||||||||||
| 635 | if (strlen(cp) >
| 0 | ||||||||||||||||||||||||||||||
| 636 | 46
| 0 | ||||||||||||||||||||||||||||||
| 637 | + 3
| 0 | ||||||||||||||||||||||||||||||
| 638 | error("%s: list entry \"%.100s\" too long", | - | ||||||||||||||||||||||||||||||
| 639 | __func__, cp); | - | ||||||||||||||||||||||||||||||
| 640 | ret = -1; | - | ||||||||||||||||||||||||||||||
| 641 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||
| 642 | } | - | ||||||||||||||||||||||||||||||
| 643 | - | |||||||||||||||||||||||||||||||
| 644 | if ( | - | ||||||||||||||||||||||||||||||
| 645 | __builtin_strspn (
| 0 | ||||||||||||||||||||||||||||||
| 646 | cp
| 0 | ||||||||||||||||||||||||||||||
| 647 | ,
| 0 | ||||||||||||||||||||||||||||||
| 648 | "0123456789abcdefABCDEF.:/"
| 0 | ||||||||||||||||||||||||||||||
| 649 | )
| 0 | ||||||||||||||||||||||||||||||
| 650 | != strlen(cp)
| 0 | ||||||||||||||||||||||||||||||
| 651 | error("%s: list entry \"%.100s\" contains invalid " | - | ||||||||||||||||||||||||||||||
| 652 | "characters", __func__, cp); | - | ||||||||||||||||||||||||||||||
| 653 | ret = -1; | - | ||||||||||||||||||||||||||||||
| 654 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 655 | - | |||||||||||||||||||||||||||||||
| 656 | - | |||||||||||||||||||||||||||||||
| 657 | r = addr_pton_cidr(cp, &match_addr, &masklen); | - | ||||||||||||||||||||||||||||||
| 658 | if (r == -1
| 0 | ||||||||||||||||||||||||||||||
| 659 | error("Invalid network entry \"%.100s\"", cp); | - | ||||||||||||||||||||||||||||||
| 660 | ret = -1; | - | ||||||||||||||||||||||||||||||
| 661 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||
| 662 | } else if (r == -2
| 0 | ||||||||||||||||||||||||||||||
| 663 | error("Inconsistent mask length for " | - | ||||||||||||||||||||||||||||||
| 664 | "network \"%.100s\"", cp); | - | ||||||||||||||||||||||||||||||
| 665 | ret = -1; | - | ||||||||||||||||||||||||||||||
| 666 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||
| 667 | } else if (r == 0
| 0 | ||||||||||||||||||||||||||||||
| 668 | ((void *)0)
| 0 | ||||||||||||||||||||||||||||||
| 669 | ) { | - | ||||||||||||||||||||||||||||||
| 670 | if (addr_netmatch(&try_addr, &match_addr,
| 0 | ||||||||||||||||||||||||||||||
| 671 | masklen) == 0
| 0 | ||||||||||||||||||||||||||||||
| 672 | ret = 1; never executed: ret = 1; | 0 | ||||||||||||||||||||||||||||||
| 673 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||||||||
| 674 | } | - | ||||||||||||||||||||||||||||||
| 675 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 676 | free(o); | - | ||||||||||||||||||||||||||||||
| 677 | - | |||||||||||||||||||||||||||||||
| 678 | return never executed: ret;return ret;never executed: return ret; | 0 | ||||||||||||||||||||||||||||||
| 679 | } | - | ||||||||||||||||||||||||||||||
| Switch to Source code | Preprocessed file |