[packages/bash] Fix fd leaks when sourcing directory. RHBZ#903833
glen
glen at pld-linux.org
Mon Apr 8 10:57:33 CEST 2013
commit d7465fdfafcede9bbc1966bac26670ad46d8398e
Author: Elan Ruusamäe <glen at delfi.ee>
Date: Mon Apr 8 11:56:43 2013 +0300
Fix fd leaks when sourcing directory. RHBZ#903833
bash-4.2-missing_closes.patch | 39 +++++++++++++++++++++++++++++++++++++++
bash.spec | 8 +++++---
2 files changed, 44 insertions(+), 3 deletions(-)
---
diff --git a/bash.spec b/bash.spec
index ed5b124..feef2c5 100644
--- a/bash.spec
+++ b/bash.spec
@@ -5,7 +5,7 @@
%define ver 4.2
%define patchlevel 45
-%define rel 1
+%define rel 2
Summary: GNU Bourne Again Shell (bash)
Summary(fr.UTF-8): Le shell Bourne Again de GNU
Summary(pl.UTF-8): Powłoka GNU Bourne Again Shell (bash)
@@ -35,6 +35,7 @@ Patch10: %{name}-act_like_sh.patch
Patch11: %{name}-elinks_cont.patch
Patch12: %{name}-pl.po-update.patch
Patch13: %{name}-format-string.patch
+Patch14: %{name}-4.2-missing_closes.patch
%patchset_source -f http://ftp.gnu.org/gnu/bash/bash-4.2-patches/bash42-%03g 1 %{patchlevel}
URL: http://www.gnu.org/software/bash/
BuildRequires: autoconf
@@ -194,6 +195,7 @@ tym pakiecie jest wersja basha skonsolidowana statycznie.
%patch11 -p1
%patch12 -p1
%patch13 -p1
+%patch14 -p1
%build
cp -f /usr/share/automake/config.* support
@@ -211,13 +213,13 @@ for mode in %{?with_static:static} shared; do
--enable-dparen-arithmetic \
--enable-separate-helpfiles \
--without-bash-malloc \
- `[ "$mode" = "static" ] && echo "--enable-static-link"` \
+ $([ "$mode" = "static" ] && echo "--enable-static-link") \
--with-installed-readline
%{__make} \
DEFS="-DHAVE_CONFIG_H -D_GNU_SOURCE"
-[ "$mode" = "static" ] && mv -f bash bash.static || :
+[ "$mode" = "static" ] && mv -f bash bash.static
done
%{?with_tests:%{__make} tests}
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
+
================================================================
---- gitweb:
http://git.pld-linux.org/gitweb.cgi/packages/bash.git/commitdiff/d7465fdfafcede9bbc1966bac26670ad46d8398e
More information about the pld-cvs-commit
mailing list