From d9a5ae7079d001a9e3b9b384f9153f591a7158bd Mon Sep 17 00:00:00 2001 From: Olaf Kirch Date: Tue, 30 Sep 2008 15:10:43 -0400 Subject: [PATCH] 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 patch fixes this issue. Signed-off-by: Olaf Kirch Signed-off-by: Steve Dickson --- src/rpc_generic.c | 6 ++++-- 1 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/rpc_generic.c b/src/rpc_generic.c index 9ada668..3aad018 100644 --- a/src/rpc_generic.c +++ b/src/rpc_generic.c @@ -254,12 +254,14 @@ __rpc_getconfip(nettype) while ((nconf = getnetconfig(confighandle)) != NULL) { if (strcmp(nconf->nc_protofmly, NC_INET) == 0 || strcmp(nconf->nc_protofmly, NC_INET6) == 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); 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); thr_setspecific(udp_key, (void *) netid_udp); -- 1.5.6