if we forget to close() in the future,
this prevent fd leak

Signed-off-by: Etienne CHAMPETIER <champetier.etie...@gmail.com>
---
 jail/elf.c | 2 +-
 jail/fs.c  | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/jail/elf.c b/jail/elf.c
index b8f2cc5..7c6076a 100644
--- a/jail/elf.c
+++ b/jail/elf.c
@@ -81,7 +81,7 @@ int lib_open(char **fullpath, const char *file)
 
        list_for_each_entry(p, &library_paths, list) {
                snprintf(path, sizeof(path), "%s/%s", p->path, file);
-               fd = open(path, O_RDONLY);
+               fd = open(path, O_RDONLY|O_CLOEXEC);
                if (fd >= 0) {
                        *fullpath = strdup(path);
                        break;
diff --git a/jail/fs.c b/jail/fs.c
index 7b7b820..f390180 100644
--- a/jail/fs.c
+++ b/jail/fs.c
@@ -116,7 +116,7 @@ int add_path_and_deps(const char *path, int readonly, int 
error, int lib)
        if (path[0] == '/') {
                if (avl_find(&mounts, path))
                        return 0;
-               fd = open(path, O_RDONLY);
+               fd = open(path, O_RDONLY|O_CLOEXEC);
                if (fd == -1)
                        return error;
                add_mount(path, readonly, error);
-- 
1.9.1
_______________________________________________
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel

Reply via email to