- fix fd leak in rpc_do_create_client() (bz 1576765).

This commit is contained in:
Ian Kent 2018-05-17 09:29:51 +08:00
parent 4ad0c4aa93
commit 6663c9103f
2 changed files with 52 additions and 1 deletions

View File

@ -0,0 +1,46 @@
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 for a check in rpc_do_create_client() that would open a new
file descriptor without checking if the passed in 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.1.4.orig/CHANGELOG
+++ autofs-5.1.4/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.
--- autofs-5.1.4.orig/lib/rpc_subs.c
+++ autofs-5.1.4/lib/rpc_subs.c
@@ -183,7 +183,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);
@@ -296,7 +296,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;

View File

@ -8,7 +8,7 @@
Summary: A tool for automatically mounting and unmounting filesystems Summary: A tool for automatically mounting and unmounting filesystems
Name: autofs Name: autofs
Version: 5.1.4 Version: 5.1.4
Release: 16%{?dist} Release: 17%{?dist}
Epoch: 1 Epoch: 1
License: GPLv2+ License: GPLv2+
Group: System Environment/Daemons Group: System Environment/Daemons
@ -38,6 +38,7 @@ Patch22: autofs-5.1.4-tiny-patch-for-autofs-typo-and-possible-bug.patch
Patch23: autofs-5.1.4-add-units-After-line-to-include-statd-service.patch Patch23: autofs-5.1.4-add-units-After-line-to-include-statd-service.patch
Patch24: autofs-5.1.4-use-systemd-sd_notify-at-startup.patch Patch24: autofs-5.1.4-use-systemd-sd_notify-at-startup.patch
Patch25: autofs-5.1.4-fix-NFS-version-mask-usage.patch Patch25: autofs-5.1.4-fix-NFS-version-mask-usage.patch
Patch26: autofs-5.1.4-fix-fd-leak-in-rpc_do_create_client.patch
%if %{with_systemd} %if %{with_systemd}
BuildRequires: systemd-units BuildRequires: systemd-units
@ -123,6 +124,7 @@ echo %{version}-%{release} > .version
%patch23 -p1 %patch23 -p1
%patch24 -p1 %patch24 -p1
%patch25 -p1 %patch25 -p1
%patch26 -p1
%build %build
LDFLAGS=-Wl,-z,now LDFLAGS=-Wl,-z,now
@ -217,6 +219,9 @@ fi
%dir /etc/auto.master.d %dir /etc/auto.master.d
%changelog %changelog
* Thu May 17 2018 Ian Kent <ikent@redhat.com> - 1:5.1.4-17
- fix fd leak in rpc_do_create_client().
* Mon Mar 26 2018 Ian Kent <ikent@redhat.com> - 1:5.1.4-16 * Mon Mar 26 2018 Ian Kent <ikent@redhat.com> - 1:5.1.4-16
- also add missing "BuildRequires: systemd-devel". - also add missing "BuildRequires: systemd-devel".