diff options
author | pfg <pfg@FreeBSD.org> | 2012-10-02 19:03:21 +0000 |
---|---|---|
committer | pfg <pfg@FreeBSD.org> | 2012-10-02 19:03:21 +0000 |
commit | 7842c9016d1bb554ec3ceff6a37e072c5556531e (patch) | |
tree | 9a0b09934d3126b529722ac58d28ff0a26554b1e /lib | |
parent | 801a570273e78622987dcab8701b018ed637f465 (diff) | |
download | FreeBSD-src-7842c9016d1bb554ec3ceff6a37e072c5556531e.zip FreeBSD-src-7842c9016d1bb554ec3ceff6a37e072c5556531e.tar.gz |
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
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libc/rpc/rpc_generic.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/libc/rpc/rpc_generic.c b/lib/libc/rpc/rpc_generic.c index ab259d5..0ac4597 100644 --- a/lib/libc/rpc/rpc_generic.c +++ b/lib/libc/rpc/rpc_generic.c @@ -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; |