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