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

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