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
411598df7a
commit
1606ad8c42
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=275452
@ -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