From owner-svn-src-all@FreeBSD.ORG Wed Oct 10 19:08:46 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id A5DFF47C; Wed, 10 Oct 2012 19:08:46 +0000 (UTC) (envelope-from pfg@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 8C7A18FC08; Wed, 10 Oct 2012 19:08:46 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q9AJ8kaJ083861; Wed, 10 Oct 2012 19:08:46 GMT (envelope-from pfg@svn.freebsd.org) Received: (from pfg@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q9AJ8kAO083859; Wed, 10 Oct 2012 19:08:46 GMT (envelope-from pfg@svn.freebsd.org) Message-Id: <201210101908.q9AJ8kAO083859@svn.freebsd.org> From: "Pedro F. Giffuni" Date: Wed, 10 Oct 2012 19:08:46 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r241408 - stable/9/lib/libc/rpc X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 10 Oct 2012 19:08:46 -0000 Author: pfg Date: Wed Oct 10 19:08:46 2012 New Revision: 241408 URL: http://svn.freebsd.org/changeset/base/241408 Log: rpc: 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. Tested by: David Wolfskill Obtained from: Bull GNU/linux NFSv4 Project (libtirpc) Modified: stable/9/lib/libc/rpc/rpc_generic.c Modified: stable/9/lib/libc/rpc/rpc_generic.c ============================================================================== --- stable/9/lib/libc/rpc/rpc_generic.c Wed Oct 10 19:07:56 2012 (r241407) +++ stable/9/lib/libc/rpc/rpc_generic.c Wed Oct 10 19:08:46 2012 (r241408) @@ -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;