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

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