don't leak file descriptors to help browser process (#455450)

This commit is contained in:
Nils Philippsen 2008-07-15 15:53:42 +00:00
parent 3477043693
commit ba752ca48e
2 changed files with 36 additions and 1 deletions

View File

@ -0,0 +1,30 @@
diff -up xsane-0.995/src/xsane.c.close-fds xsane-0.995/src/xsane.c
--- xsane-0.995/src/xsane.c.close-fds 2007-09-28 17:24:56.000000000 +0200
+++ xsane-0.995/src/xsane.c 2008-07-15 17:48:17.000000000 +0200
@@ -3681,6 +3681,8 @@ static void xsane_show_doc_via_nsr(GtkWi
char *arg[5];
struct stat st;
char netscape_lock_path[PATH_MAX];
+ int open_max;
+ int i;
DBG(DBG_proc, "xsane_show_doc_via_nsr(%s)\n", name);
@@ -3725,6 +3727,17 @@ static void xsane_show_doc_via_nsr(GtkWi
ipc_file = fdopen(xsane.ipc_pipefd[1], "w");
}
+ open_max = (int) sysconf (_SC_OPEN_MAX);
+
+ DBG(DBG_info, "closing unneeded file descriptors\n");
+
+ /* leave stdin, stdout, stderr alone */
+ for (i = 3; i < open_max; i++) {
+ /* xsane.ipc_pipefd[0] is closed by now */
+ if (i != xsane.ipc_pipefd[1])
+ close (i);
+ }
+
DBG(DBG_info, "trying to change user id for new subprocess:\n");
DBG(DBG_info, "old effective uid = %d\n", (int) geteuid());
setuid(getuid());

View File

@ -3,12 +3,13 @@
Name: xsane
Summary: X Window System front-end for the SANE scanner interface
Version: 0.995
Release: 3%{?dist}
Release: 4%{?dist}
Source0: http://www.xsane.org/download/%{name}-%{version}.tar.gz
Source1: xsane.desktop
Source2: xsane.conf.in
Patch0: xsane-0.995-xdg-open.patch
Patch1: xsane-0.995-eula-license-size.patch
Patch2: xsane-0.995-close-fds.patch
License: GPLv2+
URL: http://www.xsane.org/
Group: Applications/Multimedia
@ -41,6 +42,7 @@ installed to use this package.
%setup -q
%patch0 -p1 -b .xdg-open
%patch1 -p1 -b .eula-license-size
%patch2 -p1 -b .close-fds
%build
%configure --enable-gimp
@ -105,6 +107,9 @@ fi
%config(noreplace) %{_sysconfdir}/gimp/plugins.d/xsane.conf
%changelog
* Tue Jul 15 2008 Nils Philippsen <nphilipp@redhat.com> - 0.995-4
- don't leak file descriptors to help browser process (#455450)
* Tue Feb 19 2008 Fedora Release Engineering <rel-eng@fedoraproject.org> - 0.995-3
- Autorebuild for GCC 4.3