Do not corrupt the listen string when parsing it.
This fixes problem with ctld reload when it is configured to listen on two portals with same IP, but different ports. MFC after: 1 week
This commit is contained in:
parent
826327d5db
commit
a0aca4af78
@ -643,10 +643,11 @@ static int
|
||||
parse_addr_port(char *arg, const char *def_port, struct addrinfo **ai)
|
||||
{
|
||||
struct addrinfo hints;
|
||||
char *addr, *ch;
|
||||
char *str, *addr, *ch;
|
||||
const char *port;
|
||||
int error, colons = 0;
|
||||
|
||||
str = arg = strdup(arg);
|
||||
if (arg[0] == '[') {
|
||||
/*
|
||||
* IPv6 address in square brackets, perhaps with port.
|
||||
@ -659,8 +660,10 @@ parse_addr_port(char *arg, const char *def_port, struct addrinfo **ai)
|
||||
port = def_port;
|
||||
} else if (arg[0] == ':') {
|
||||
port = arg + 1;
|
||||
} else
|
||||
} else {
|
||||
free(str);
|
||||
return (1);
|
||||
}
|
||||
} else {
|
||||
/*
|
||||
* Either IPv6 address without brackets - and without
|
||||
@ -687,9 +690,8 @@ parse_addr_port(char *arg, const char *def_port, struct addrinfo **ai)
|
||||
hints.ai_socktype = SOCK_STREAM;
|
||||
hints.ai_flags = AI_PASSIVE;
|
||||
error = getaddrinfo(addr, port, &hints, ai);
|
||||
if (error != 0)
|
||||
return (1);
|
||||
return (0);
|
||||
free(str);
|
||||
return ((error != 0) ? 1 : 0);
|
||||
}
|
||||
|
||||
int
|
||||
|
Loading…
Reference in New Issue
Block a user