svn commit: r275674 - stable/10/usr.sbin/ctld
Alexander Motin
mav at FreeBSD.org
Wed Dec 10 08:53:42 UTC 2014
Author: mav
Date: Wed Dec 10 08:53:41 2014
New Revision: 275674
URL: https://svnweb.freebsd.org/changeset/base/275674
Log:
MFC r275452: 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.
Modified:
stable/10/usr.sbin/ctld/ctld.c
Directory Properties:
stable/10/ (props changed)
Modified: stable/10/usr.sbin/ctld/ctld.c
==============================================================================
--- stable/10/usr.sbin/ctld/ctld.c Wed Dec 10 08:52:47 2014 (r275673)
+++ stable/10/usr.sbin/ctld/ctld.c Wed Dec 10 08:53:41 2014 (r275674)
@@ -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 *d
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 *d
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
More information about the svn-src-all
mailing list