MCPcopy Create free account
hub / github.com/git/git / parse_host_arg

Function parse_host_arg

daemon.c:590–621  ·  view source on GitHub ↗

* 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. */

Source from the content-addressed store, hash-verified

588 * argument, or 'extra_args' if there is no host argument.
589 */
590static 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
623static void parse_extra_args(struct hostinfo *hi, struct strvec *env,
624 char *extra_args, int buflen)

Callers 1

parse_extra_argsFunction · 0.85

Calls 5

loginfoFunction · 0.85
parse_host_and_portFunction · 0.85
sanitize_clientFunction · 0.85
canonicalize_clientFunction · 0.85
dieFunction · 0.70

Tested by

no test coverage detected