* Parses a host of the form [:port] * paddr is used to create a list in the order of input * **paddr is the ->next pointer of the last entry (or s->addrs) * *paddr is the variable used to keep track of **paddr between calls * port is the default port to assume */
| 146 | * port is the default port to assume |
| 147 | */ |
| 148 | static const char *get_addresses(apr_pool_t *p, const char *w_, |
| 149 | server_addr_rec ***paddr, |
| 150 | apr_port_t default_port) |
| 151 | { |
| 152 | apr_sockaddr_t *my_addr; |
| 153 | server_addr_rec *sar; |
| 154 | char *w, *host, *scope_id; |
| 155 | int wild_port; |
| 156 | apr_size_t wlen; |
| 157 | apr_port_t port; |
| 158 | apr_status_t rv; |
| 159 | |
| 160 | if (*w_ == '\0') |
| 161 | return NULL; |
| 162 | |
| 163 | wlen = strlen(w_); /* wlen must be > 0 at this point */ |
| 164 | w = apr_pstrmemdup(p, w_, wlen); |
| 165 | /* apr_parse_addr_port() doesn't understand ":*" so handle that first. */ |
| 166 | wild_port = 0; |
| 167 | if (w[wlen - 1] == '*') { |
| 168 | if (wlen < 2) { |
| 169 | wild_port = 1; |
| 170 | } |
| 171 | else if (w[wlen - 2] == ':') { |
| 172 | w[wlen - 2] = '\0'; |
| 173 | wild_port = 1; |
| 174 | } |
| 175 | } |
| 176 | rv = apr_parse_addr_port(&host, &scope_id, &port, w, p); |
| 177 | /* If the string is "80", apr_parse_addr_port() will be happy and set |
| 178 | * host to NULL and port to 80, so watch out for that. |
| 179 | */ |
| 180 | if (rv != APR_SUCCESS) { |
| 181 | return "The address or port is invalid"; |
| 182 | } |
| 183 | if (!host) { |
| 184 | return "Missing address for VirtualHost"; |
| 185 | } |
| 186 | #if !APR_VERSION_AT_LEAST(1,7,0) |
| 187 | if (scope_id) { |
| 188 | return apr_pstrcat(p, |
| 189 | "Scope ID in address '", w, |
| 190 | "' not supported with APR " APR_VERSION_STRING, |
| 191 | NULL); |
| 192 | } |
| 193 | #endif |
| 194 | if (!port && !wild_port) { |
| 195 | port = default_port; |
| 196 | } |
| 197 | |
| 198 | if (strcmp(host, "*") == 0 || strcasecmp(host, "_default_") == 0) { |
| 199 | rv = apr_sockaddr_info_get(&my_addr, NULL, APR_UNSPEC, port, 0, p); |
| 200 | if (rv) { |
| 201 | return "Could not determine a wildcard address ('0.0.0.0') -- " |
| 202 | "check resolver configuration."; |
| 203 | } |
| 204 | } |
| 205 | else { |
no test coverage detected