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

7f6688
autofs-5.1.4 - fix fd leak in rpc_do_create_client()
7f6688
7f6688
From: Ian Kent <raven@themaw.net>
7f6688
7f6688
Commit 94f87e203a (fix create_client() RPC client handling) fixed
7f6688
possible use of an invalid RPC client handle but the change neglected
7f6688
to account of a check in rpc_do_create_client() that would open a new
7f6688
file descriptor without checking if the passed if descriptor was
7f6688
already opened.
7f6688
7f6688
Signed-off-by: Ian Kent <raven@themaw.net>
7f6688
---
7f6688
 CHANGELOG      |    1 +
7f6688
 lib/rpc_subs.c |    4 ++--
7f6688
 2 files changed, 3 insertions(+), 2 deletions(-)
7f6688
7f6688
--- autofs-5.0.7.orig/CHANGELOG
7f6688
+++ autofs-5.0.7/CHANGELOG
7f6688
@@ -297,6 +297,7 @@
7f6688
 - fix error return in do_nfs_mount().
7f6688
 - fix create_client() RPC client handling.
7f6688
 - dont allow trailing slash in master map mount points.
7f6688
+- fix fd leak in rpc_do_create_client().
7f6688
 
7f6688
 25/07/2012 autofs-5.0.7
7f6688
 =======================
7f6688
--- autofs-5.0.7.orig/lib/rpc_subs.c
7f6688
+++ autofs-5.0.7/lib/rpc_subs.c
7f6688
@@ -192,7 +192,7 @@ static int rpc_do_create_client(struct s
7f6688
 	in4_laddr.sin_addr.s_addr = htonl(INADDR_ANY);
7f6688
 	slen = sizeof(struct sockaddr_in);
7f6688
 
7f6688
-	if (!info->client) {
7f6688
+	if (!info->client && *fd == RPC_ANYSOCK) {
7f6688
 		struct sockaddr *laddr;
7f6688
 
7f6688
 		*fd = open_sock(addr->sa_family, type, proto);
7f6688
@@ -304,7 +304,7 @@ static int rpc_do_create_client(struct s
7f6688
 	 * it would bind to a reserved port, which has been shown to
7f6688
 	 * exhaust the reserved port range in some situations.
7f6688
 	 */
7f6688
-	if (!info->client) {
7f6688
+	if (!info->client && *fd == RPC_ANYSOCK) {
7f6688
 		*fd = open_sock(addr->sa_family, type, proto);
7f6688
 		if (*fd < 0) {
7f6688
 			ret = -errno;