diff options
author | Thomas Blume <Thomas.Blume@suse.com> | 2018-04-18 08:44:49 -0400 |
---|---|---|
committer | Steve Dickson <steved@redhat.com> | 2018-04-18 08:45:45 -0400 |
commit | 25d38d744997d5ff03d8b0f2cdd79c0fb7185cca (patch) | |
tree | 99cecea1c6f45763f7dc51201da47124b0efbfd9 | |
parent | 2802259184ada839793152ed0a0f130065f82dfd (diff) | |
download | ti-rpc-25d38d744997d5ff03d8b0f2cdd79c0fb7185cca.tar.gz |
Fix regression introduced by change rpc version order patchlibtirpc-1-0-4-rc1
Fix a socket leak introduced by commit 5e7b57bc20bd9cadff
(rpcinfo: change order of version to be tried to 4, 3, 2)
The new function __try_protocol_version_2 doesn't return
the client, so it can't be closed via CLNT_DESTROY in the
calling function.
Signed-off-by: Thomas Blume <Thomas.Blume@suse.com>
Signed-off-by: Steve Dickson <steved@redhat.com>
-rw-r--r-- | src/rpcb_clnt.c | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/src/rpcb_clnt.c b/src/rpcb_clnt.c index a94fc73..4b44364 100644 --- a/src/rpcb_clnt.c +++ b/src/rpcb_clnt.c @@ -752,7 +752,7 @@ __try_protocol_version_2(program, version, nconf, host, tp) client = getpmaphandle(nconf, host, &parms.r_addr); if (client == NULL) - return (NULL); + goto error; /* * Set retry timeout. @@ -771,11 +771,11 @@ __try_protocol_version_2(program, version, nconf, host, tp) if (clnt_st != RPC_SUCCESS) { rpc_createerr.cf_stat = RPC_PMAPFAILURE; clnt_geterr(client, &rpc_createerr.cf_error); - return (NULL); + goto error; } else if (port == 0) { pmapaddress = NULL; rpc_createerr.cf_stat = RPC_PROGNOTREGISTERED; - return (NULL); + goto error; } port = htons(port); CLNT_CONTROL(client, CLGET_SVC_ADDR, (char *)&remote); @@ -789,14 +789,24 @@ __try_protocol_version_2(program, version, nconf, host, tp) free(pmapaddress); pmapaddress = NULL; } - return (NULL); + goto error; } memcpy(pmapaddress->buf, remote.buf, remote.len); memcpy(&((char *)pmapaddress->buf)[sizeof (short)], (char *)(void *)&port, sizeof (short)); pmapaddress->len = pmapaddress->maxlen = remote.len; + CLNT_DESTROY(client); return pmapaddress; + +error: + if (client) { + CLNT_DESTROY(client); + client = NULL; + + } + return (NULL); + } #endif |