* Read the host as supplied by the client connection. * * Returns a pointer to the character after the NUL byte terminating the host * argument, or 'extra_args' if there is no host argument. */
| 588 | * argument, or 'extra_args' if there is no host argument. |
| 589 | */ |
| 590 | static char *parse_host_arg(struct hostinfo *hi, char *extra_args, int buflen) |
| 591 | { |
| 592 | char *val; |
| 593 | int vallen; |
| 594 | char *end = extra_args + buflen; |
| 595 | |
| 596 | if (extra_args < end && *extra_args) { |
| 597 | hi->saw_extended_args = 1; |
| 598 | if (strncasecmp("host=", extra_args, 5) == 0) { |
| 599 | val = extra_args + 5; |
| 600 | vallen = strlen(val) + 1; |
| 601 | loginfo("Extended attribute \"host\": %s", val); |
| 602 | if (*val) { |
| 603 | /* Split <host>:<port> at colon. */ |
| 604 | char *host; |
| 605 | char *port; |
| 606 | parse_host_and_port(val, &host, &port); |
| 607 | if (port) |
| 608 | sanitize_client(&hi->tcp_port, port); |
| 609 | canonicalize_client(&hi->hostname, host); |
| 610 | hi->hostname_lookup_done = 0; |
| 611 | } |
| 612 | |
| 613 | /* On to the next one */ |
| 614 | extra_args = val + vallen; |
| 615 | } |
| 616 | if (extra_args < end && *extra_args) |
| 617 | die("Invalid request"); |
| 618 | } |
| 619 | |
| 620 | return extra_args; |
| 621 | } |
| 622 | |
| 623 | static void parse_extra_args(struct hostinfo *hi, struct strvec *env, |
| 624 | char *extra_args, int buflen) |
no test coverage detected