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

Function parse_host_and_port

daemon.c:527–552  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

525}
526
527static void parse_host_and_port(char *hostport, char **host,
528 char **port)
529{
530 if (*hostport == '[') {
531 char *end;
532
533 end = strchr(hostport, ']');
534 if (!end)
535 die("Invalid request ('[' without ']')");
536 *end = '\0';
537 *host = hostport + 1;
538 if (!end[1])
539 *port = NULL;
540 else if (end[1] == ':')
541 *port = end + 2;
542 else
543 die("Garbage after end of host part");
544 } else {
545 *host = hostport;
546 *port = strrchr(hostport, ':');
547 if (*port) {
548 **port = '\0';
549 ++*port;
550 }
551 }
552}
553
554/*
555 * Sanitize a string from the client so that it's OK to be inserted into a

Callers 1

parse_host_argFunction · 0.85

Calls 1

dieFunction · 0.70

Tested by

no test coverage detected