Tidy domain parsing, make --server=/*/1.2.3.4 equivalent to --server=1.2.3.4

This commit is contained in:
Simon Kelley
2021-07-03 12:56:50 +01:00
parent 0c95a5ff53
commit a92c6d77dc
2 changed files with 16 additions and 15 deletions

View File

@@ -582,18 +582,23 @@ int add_update_server(int flags,
struct server *serv = NULL; struct server *serv = NULL;
char *alloc_domain; char *alloc_domain;
if (!domain || strlen(domain) == 0) if (!domain)
alloc_domain = whine_malloc(1); domain = "";
else
{ /* .domain == domain, for historical reasons. */
if (*domain == '*') if (*domain == '.')
while (*domain == '.') domain++;
else if (*domain == '*')
{ {
domain++; domain++;
if (domain != 0)
flags |= SERV_WILDCARD; flags |= SERV_WILDCARD;
} }
if (!(alloc_domain = canonicalise((char *)domain, NULL)))
if (*domain == 0)
alloc_domain = whine_malloc(1);
else if (!(alloc_domain = canonicalise((char *)domain, NULL)))
return 0; return 0;
}
/* See if there is a suitable candidate, and unmark /* See if there is a suitable candidate, and unmark
only do this for forwarding servers, not only do this for forwarding servers, not

View File

@@ -2636,11 +2636,7 @@ static int one_opt(int option, char *arg, char *errstr, char *gen_err, int comma
{ {
char *last; char *last;
arg++; domain = lastdomain = ++arg;
/* elide leading dots - they are implied in the search algorithm */
while (*arg == '.') arg++;
domain = lastdomain = arg;
while ((last = split_chr(arg, '/'))) while ((last = split_chr(arg, '/')))
{ {