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

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