summaryrefslogtreecommitdiffstats
path: root/lib/libc/rpc
diff options
context:
space:
mode:
authoriedowse <iedowse@FreeBSD.org>2001-08-02 21:31:21 +0000
committeriedowse <iedowse@FreeBSD.org>2001-08-02 21:31:21 +0000
commit064d84b2521ca869363580e56d314e48668cb3ab (patch)
treeb33e133d4c8be09c2bb35dc17a95aba75ade6444 /lib/libc/rpc
parent982fd84b01201a3e526bacc2c658932729cb7725 (diff)
downloadFreeBSD-src-064d84b2521ca869363580e56d314e48668cb3ab.zip
FreeBSD-src-064d84b2521ca869363580e56d314e48668cb3ab.tar.gz
In getclnthandle(), if the address is found in the cache we need
to strdup() the address string before returning it via *targaddr because the caller will free the string. Change the comment at the top of getclnthandle() to clarify that the caller is responsible for freeing *targaddr. Noticed by: sobomax
Diffstat (limited to 'lib/libc/rpc')
-rw-r--r--lib/libc/rpc/rpcb_clnt.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/libc/rpc/rpcb_clnt.c b/lib/libc/rpc/rpcb_clnt.c
index d70aaec..e626225 100644
--- a/lib/libc/rpc/rpcb_clnt.c
+++ b/lib/libc/rpc/rpcb_clnt.c
@@ -279,7 +279,10 @@ add_cache(host, netid, taddr, uaddr)
/*
* This routine will return a client handle that is connected to the
- * rpcbind. Returns NULL on error and free's everything.
+ * rpcbind. If targaddr is non-NULL, the "universal address" of the
+ * host will be stored in *targaddr; the caller is responsible for
+ * freeing this string.
+ * On error, returns NULL and free's everything.
*/
static CLIENT *
getclnthandle(host, nconf, targaddr)
@@ -308,7 +311,7 @@ getclnthandle(host, nconf, targaddr)
(rpcprog_t)RPCBPROG, (rpcvers_t)RPCBVERS4, 0, 0);
if (client != NULL) {
if (targaddr)
- *targaddr = ad_cache->ac_uaddr;
+ *targaddr = strdup(ad_cache->ac_uaddr);
rwlock_unlock(&rpcbaddr_cache_lock);
return (client);
}
OpenPOWER on IntegriCloud