Fix fd leaks
Resolves: #903833 Signed-off-by: Roman Rakus <rrakus@redhat.com>
This commit is contained in:
parent
efcdbec69c
commit
ef50169abe
39
bash-4.2-missing_closes.patch
Normal file
39
bash-4.2-missing_closes.patch
Normal file
@ -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@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
|
||||||
|
|
10
bash.spec
10
bash.spec
@ -6,7 +6,7 @@
|
|||||||
Version: %{baseversion}%{patchleveltag}
|
Version: %{baseversion}%{patchleveltag}
|
||||||
Name: bash
|
Name: bash
|
||||||
Summary: The GNU Bourne Again shell
|
Summary: The GNU Bourne Again shell
|
||||||
Release: 1%{?dist}
|
Release: 2%{?dist}
|
||||||
Group: System Environment/Shells
|
Group: System Environment/Shells
|
||||||
License: GPLv3+
|
License: GPLv3+
|
||||||
Url: http://www.gnu.org/software/bash
|
Url: http://www.gnu.org/software/bash
|
||||||
@ -109,6 +109,9 @@ Patch124: bash-4.2-signal.patch
|
|||||||
# https://www.securecoding.cert.org/confluence/display/seccode/INT32-C.+Ensure+that+operations+on+signed+integers+do+not+result+in+overflow
|
# https://www.securecoding.cert.org/confluence/display/seccode/INT32-C.+Ensure+that+operations+on+signed+integers+do+not+result+in+overflow
|
||||||
Patch125: bash-4.2-size_type.patch
|
Patch125: bash-4.2-size_type.patch
|
||||||
|
|
||||||
|
# 903833, Fix missing close(), fixes fd leaks
|
||||||
|
Patch126: bash-4.2-missing_closes.patch
|
||||||
|
|
||||||
BuildRequires: texinfo bison
|
BuildRequires: texinfo bison
|
||||||
BuildRequires: ncurses-devel
|
BuildRequires: ncurses-devel
|
||||||
BuildRequires: autoconf, gettext
|
BuildRequires: autoconf, gettext
|
||||||
@ -206,6 +209,7 @@ This package contains documentation files for %{name}.
|
|||||||
%patch123 -p1
|
%patch123 -p1
|
||||||
%patch124 -p1 -b .signal
|
%patch124 -p1 -b .signal
|
||||||
%patch125 -p1 -b .size_type
|
%patch125 -p1 -b .size_type
|
||||||
|
%patch126 -p1 -b .missing_closes
|
||||||
|
|
||||||
echo %{version} > _distribution
|
echo %{version} > _distribution
|
||||||
echo %{release} > _patchlevel
|
echo %{release} > _patchlevel
|
||||||
@ -398,6 +402,10 @@ end
|
|||||||
#%doc doc/*.ps doc/*.0 doc/*.html doc/article.txt
|
#%doc doc/*.ps doc/*.0 doc/*.html doc/article.txt
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Thu Jan 31 2013 Roman Rakus <rrakus@redhat.com> - 4.2.42-2
|
||||||
|
- Fix fd leaks
|
||||||
|
Resolves: #903833
|
||||||
|
|
||||||
* Thu Jan 03 2013 Roman Rakus <rrakus@redhat.com> - 4.2.42-1
|
* Thu Jan 03 2013 Roman Rakus <rrakus@redhat.com> - 4.2.42-1
|
||||||
- Patchlevel 42
|
- Patchlevel 42
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user