diff --git a/CHANGELOG b/CHANGELOG index add68aa..ebabadc 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -24,6 +24,7 @@ xx/xx/2018 autofs-5.1.5 - add units After line to include statd service. - use systemd sd_notify() at startup. - fix NFS version mask usage. +- fix fd leak in rpc_do_create_client(). 19/12/2017 autofs-5.1.4 - fix spec file url. diff --git a/lib/rpc_subs.c b/lib/rpc_subs.c index cc83e84..9451c45 100644 --- a/lib/rpc_subs.c +++ b/lib/rpc_subs.c @@ -183,7 +183,7 @@ static int rpc_do_create_client(struct sockaddr *addr, struct conn_info *info, i 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); @@ -296,7 +296,7 @@ static int rpc_do_create_client(struct sockaddr *addr, struct conn_info *info, i * 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;