[bash/f17] Fix fd leaks
Roman Rakus
rrakus at fedoraproject.org
Thu Jan 31 14:37:16 UTC 2013
commit 5ee28f6c2bb5475f73e3dda36172cd94efddf3be
Author: Roman Rakus <rrakus at redhat.com>
Date: Thu Jan 31 15:36:38 2013 +0100
Fix fd leaks
Resolves: #903833
Signed-off-by: Roman Rakus <rrakus at redhat.com>
bash-4.2-missing_closes.patch | 39 +++++++++++++++++++++++++++++++++++++++
bash.spec | 10 +++++++++-
2 files changed, 48 insertions(+), 1 deletions(-)
---
diff --git a/bash-4.2-missing_closes.patch b/bash-4.2-missing_closes.patch
new file mode 100644
index 0000000..8dfd1d4
--- /dev/null
+++ b/bash-4.2-missing_closes.patch
@@ -0,0 +1,39 @@
+There are missing calls of close() leading to resource leak (fd leak).
+Simple reproducer:
+. /
+and /proc/$$/fd contain one open fd for each above call
+
+Signed-off-by: Roman Rakus <rrakus at redhat.com>
+---
+ builtins/evalfile.c | 3 +++
+ 1 file changed, 3 insertions(+)
+
+diff --git a/builtins/evalfile.c b/builtins/evalfile.c
+index 60f89d1..d30bd96 100644
+--- a/builtins/evalfile.c
++++ b/builtins/evalfile.c
+@@ -133,11 +133,13 @@ file_error_and_exit:
+ if (S_ISDIR (finfo.st_mode))
+ {
+ (*errfunc) (_("%s: is a directory"), filename);
++ close(fd);
+ return ((flags & FEVAL_BUILTIN) ? EXECUTION_FAILURE : -1);
+ }
+ else if ((flags & FEVAL_REGFILE) && S_ISREG (finfo.st_mode) == 0)
+ {
+ (*errfunc) (_("%s: not a regular file"), filename);
++ close(fd);
+ return ((flags & FEVAL_BUILTIN) ? EXECUTION_FAILURE : -1);
+ }
+
+@@ -146,6 +148,7 @@ file_error_and_exit:
+ if (file_size != finfo.st_size || file_size + 1 < file_size)
+ {
+ (*errfunc) (_("%s: file is too large"), filename);
++ close(fd);
+ return ((flags & FEVAL_BUILTIN) ? EXECUTION_FAILURE : -1);
+ }
+
+--
+1.7.11.7
+
diff --git a/bash.spec b/bash.spec
index 1c654b6..236f440 100644
--- a/bash.spec
+++ b/bash.spec
@@ -6,7 +6,7 @@
Version: %{baseversion}%{patchleveltag}
Name: bash
Summary: The GNU Bourne Again shell
-Release: 2%{?dist}
+Release: 3%{?dist}
Group: System Environment/Shells
License: GPLv3+
Url: http://www.gnu.org/software/bash
@@ -97,6 +97,9 @@ Patch121: bash-4.2-coverity.patch
# Don't call malloc in signal handler
Patch122: bash-4.1-defer-sigchld-trap.patch
+# 903833, Fix missing close(), fixes fd leaks
+Patch123: bash-4.2-missing_closes.patch
+
BuildRequires: texinfo bison
BuildRequires: ncurses-devel
BuildRequires: autoconf, gettext
@@ -188,6 +191,7 @@ This package contains documentation files for %{name}.
%patch120 -p1 -b .logout
%patch121 -p1 -b .coverity
%patch122 -p1 -b .defer_sigchld_trap
+%patch123 -p1 -b .missing_closes
echo %{version} > _distribution
echo %{release} > _patchlevel
@@ -357,6 +361,10 @@ end
#%doc doc/*.ps doc/*.0 doc/*.html doc/article.txt
%changelog
+* Thu Jan 31 2013 Roman Rakus <rrakus at redhat.com> - 4.2.39-3
+- Fix fd leaks
+ Resolves: #903833
+
* Tue Nov 27 2012 Roman Rakus <rrakus at redhat.com> - 4.2.39-2
- Create bashbug symlink
More information about the scm-commits
mailing list