File 0002-Fix-regression-introduced-by-change-rpc-version-orde.patch of Package libtirpc.7906

From 926a927f095ea0f3b6b4fedd807074383babe7b3 Mon Sep 17 00:00:00 2001
From: Thomas Blume <Thomas.Blume@suse.com>
Date: Wed, 18 Apr 2018 08:44:49 -0400
Subject: [PATCH 2/3] Fix regression introduced by change rpc version order
 patch

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>
(cherry picked from commit 25d38d744997d5ff03d8b0f2cdd79c0fb7185cca)
---
 src/rpcb_clnt.c | 18 ++++++++++++++----
 1 file 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
 
-- 
2.16.4