Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 10 Dec 2014 08:53:41 +0000 (UTC)
From:      Alexander Motin <mav@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org
Subject:   svn commit: r275674 - stable/10/usr.sbin/ctld
Message-ID:  <201412100853.sBA8rfe0048036@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201412100853.sBA8rfe0048036>