]> git.pld-linux.org Git - packages/bash.git/commitdiff
Fix fd leaks when sourcing directory. RHBZ#903833 auto/th/bash-4.2.45-2 auto/ti/bash-4.2.45-2
authorElan Ruusamäe <glen@delfi.ee>
Mon, 8 Apr 2013 08:56:43 +0000 (11:56 +0300)
committerElan Ruusamäe <glen@delfi.ee>
Mon, 8 Apr 2013 08:56:43 +0000 (11:56 +0300)
bash-4.2-missing_closes.patch [new file with mode: 0644]
bash.spec

diff --git a/bash-4.2-missing_closes.patch b/bash-4.2-missing_closes.patch
new file mode 100644 (file)
index 0000000..8dfd1d4
--- /dev/null
@@ -0,0 +1,39 @@
+There are missing calls of close() leading to resource leak (fd leak).\r
+Simple reproducer:\r
+. /\r
+and /proc/$$/fd contain one open fd for each above call\r
+\r
+Signed-off-by: Roman Rakus <rrakus@redhat.com>\r
+---\r
+ builtins/evalfile.c | 3 +++\r
+ 1 file changed, 3 insertions(+)\r
+\r
+diff --git a/builtins/evalfile.c b/builtins/evalfile.c\r
+index 60f89d1..d30bd96 100644\r
+--- a/builtins/evalfile.c\r
++++ b/builtins/evalfile.c\r
+@@ -133,11 +133,13 @@ file_error_and_exit:\r
+   if (S_ISDIR (finfo.st_mode))\r
+     {\r
+       (*errfunc) (_("%s: is a directory"), filename);\r
++      close(fd);\r
+       return ((flags & FEVAL_BUILTIN) ? EXECUTION_FAILURE : -1);\r
+     }\r
+   else if ((flags & FEVAL_REGFILE) && S_ISREG (finfo.st_mode) == 0)\r
+     {\r
+       (*errfunc) (_("%s: not a regular file"), filename);\r
++      close(fd);\r
+       return ((flags & FEVAL_BUILTIN) ? EXECUTION_FAILURE : -1);\r
+     }\r
\r
+@@ -146,6 +148,7 @@ file_error_and_exit:\r
+   if (file_size != finfo.st_size || file_size + 1 < file_size)\r
+     {\r
+       (*errfunc) (_("%s: file is too large"), filename);\r
++      close(fd);\r
+       return ((flags & FEVAL_BUILTIN) ? EXECUTION_FAILURE : -1);\r
+     }      \r
\r
+-- \r
+1.7.11.7\r
+\r
index ed5b124387d377126bd2fe29625920490fcfd72b..feef2c555a3208f4fa298eb35f9eb5a2e01ddf47 100644 (file)
--- 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}
This page took 0.083188 seconds and 4 git commands to generate.