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