Blame SOURCES/autofs-5.1.4-fix-fd-leak-in-rpc_do_create_client.patch

135b98
autofs-5.1.4 - fix fd leak in rpc_do_create_client()
135b98
135b98
From: Ian Kent <raven@themaw.net>
135b98
135b98
Commit 94f87e203a (fix create_client() RPC client handling) fixed
135b98
possible use of an invalid RPC client handle but the change neglected
135b98
to account for a check in rpc_do_create_client() that would open a new
135b98
file descriptor without checking if the passed in descriptor was
135b98
already opened.
135b98
135b98
Signed-off-by: Ian Kent <raven@themaw.net>
135b98
---
135b98
 CHANGELOG      |    1 +
135b98
 lib/rpc_subs.c |    4 ++--
135b98
 2 files changed, 3 insertions(+), 2 deletions(-)
135b98
135b98
--- autofs-5.1.4.orig/CHANGELOG
135b98
+++ autofs-5.1.4/CHANGELOG
135b98
@@ -24,6 +24,7 @@ xx/xx/2018 autofs-5.1.5
135b98
 - add units After line to include statd service.
135b98
 - use systemd sd_notify() at startup.
135b98
 - fix NFS version mask usage.
135b98
+- fix fd leak in rpc_do_create_client().
135b98
 
135b98
 19/12/2017 autofs-5.1.4
135b98
 - fix spec file url.
135b98
--- autofs-5.1.4.orig/lib/rpc_subs.c
135b98
+++ autofs-5.1.4/lib/rpc_subs.c
135b98
@@ -183,7 +183,7 @@ static int rpc_do_create_client(struct s
135b98
 	in4_laddr.sin_addr.s_addr = htonl(INADDR_ANY);
135b98
 	slen = sizeof(struct sockaddr_in);
135b98
 
135b98
-	if (!info->client) {
135b98
+	if (!info->client && *fd == RPC_ANYSOCK) {
135b98
 		struct sockaddr *laddr;
135b98
 
135b98
 		*fd = open_sock(addr->sa_family, type, proto);
135b98
@@ -296,7 +296,7 @@ static int rpc_do_create_client(struct s
135b98
 	 * it would bind to a reserved port, which has been shown to
135b98
 	 * exhaust the reserved port range in some situations.
135b98
 	 */
135b98
-	if (!info->client) {
135b98
+	if (!info->client && *fd == RPC_ANYSOCK) {
135b98
 		*fd = open_sock(addr->sa_family, type, proto);
135b98
 		if (*fd < 0) {
135b98
 			ret = -errno;