Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 2 Oct 2012 19:03:21 +0000 (UTC)
From:      "Pedro F. Giffuni" <pfg@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r241142 - head/lib/libc/rpc
Message-ID:  <201210021903.q92J3LIe088928@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: pfg
Date: Tue Oct  2 19:03:21 2012
New Revision: 241142
URL: http://svn.freebsd.org/changeset/base/241142

Log:
  Fix __rpc_getconfip
  
  __rpc_getconfip is supposed to return the first netconf
  entry supporting tcp or udp, respectively. The code will
  currently return the *last* entry, plus it will leak
  memory when there is more than one such entry.
  
  This change matches the reference (OpenSolaris)
  implementation.
  
  Tested by:	David Wolfskill
  Obtained from:	Bull GNU/linux NFSv4 Project (libtirpc)
  MFC after:	1 week

Modified:
  head/lib/libc/rpc/rpc_generic.c

Modified: head/lib/libc/rpc/rpc_generic.c
==============================================================================
--- head/lib/libc/rpc/rpc_generic.c	Tue Oct  2 19:00:56 2012	(r241141)
+++ head/lib/libc/rpc/rpc_generic.c	Tue Oct  2 19:03:21 2012	(r241142)
@@ -269,7 +269,8 @@ __rpc_getconfip(nettype)
 		}
 		while ((nconf = getnetconfig(confighandle)) != NULL) {
 			if (strcmp(nconf->nc_protofmly, NC_INET) == 0) {
-				if (strcmp(nconf->nc_proto, NC_TCP) == 0) {
+				if (strcmp(nconf->nc_proto, NC_TCP) == 0 &&
+				    netid_tcp == NULL) {
 					netid_tcp = strdup(nconf->nc_netid);
 					if (main_thread)
 						netid_tcp_main = netid_tcp;
@@ -277,7 +278,8 @@ __rpc_getconfip(nettype)
 						thr_setspecific(tcp_key,
 							(void *) netid_tcp);
 				} else
-				if (strcmp(nconf->nc_proto, NC_UDP) == 0) {
+				if (strcmp(nconf->nc_proto, NC_UDP) == 0 &&
+				    netid_udp == NULL) {
 					netid_udp = strdup(nconf->nc_netid);
 					if (main_thread)
 						netid_udp_main = netid_udp;



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