aboutsummaryrefslogtreecommitdiff
path: root/lib/libc/rpc
diff options
context:
space:
mode:
authorPedro F. Giffuni <pfg@FreeBSD.org>2012-10-02 19:03:21 +0000
committerPedro F. Giffuni <pfg@FreeBSD.org>2012-10-02 19:03:21 +0000
commitb4e7a879abd49237fb33ace363aba9a3c45b7b3f (patch)
tree9a0b09934d3126b529722ac58d28ff0a26554b1e /lib/libc/rpc
parentf3c3ef7b2a3a6eb0501b88f262c01a44f727a29c (diff)
downloadsrc-b4e7a879abd49237fb33ace363aba9a3c45b7b3f.tar.gz
src-b4e7a879abd49237fb33ace363aba9a3c45b7b3f.zip
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
Notes
Notes: svn path=/head/; revision=241142
Diffstat (limited to 'lib/libc/rpc')
-rw-r--r--lib/libc/rpc/rpc_generic.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/libc/rpc/rpc_generic.c b/lib/libc/rpc/rpc_generic.c
index ab259d59f30f..0ac4597bc78f 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;