diff options
author | Sergey Bugaev <bugaevc@gmail.com> | 2023-04-19 19:02:03 +0300 |
---|---|---|
committer | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2023-04-22 13:50:14 +0200 |
commit | 533deafbdf189f5fbb280c28562dd43ace2f4b0f (patch) | |
tree | 292d1cf07d52199a9dd247c6bb06f5566c218855 /catgets/open_catalog.c | |
parent | 28a441cc577e31e95742b9ec5f1737b86749b712 (diff) | |
download | glibc-533deafbdf189f5fbb280c28562dd43ace2f4b0f.tar.gz glibc-533deafbdf189f5fbb280c28562dd43ace2f4b0f.tar.xz glibc-533deafbdf189f5fbb280c28562dd43ace2f4b0f.zip |
Use O_CLOEXEC in more places (BZ #15722)
When opening a temporary file without O_CLOEXEC we risk leaking the file descriptor if another thread calls (fork and then) exec while we have the fd open. Fix this by consistently passing O_CLOEXEC everywhere where we open a file for internal use (and not to return it to the user, in which case the API defines whether or not the close-on-exec flag shall be set on the returned fd). Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org> Signed-off-by: Sergey Bugaev <bugaevc@gmail.com> Message-Id: <20230419160207.65988-4-bugaevc@gmail.com>
Diffstat (limited to 'catgets/open_catalog.c')
-rw-r--r-- | catgets/open_catalog.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/catgets/open_catalog.c b/catgets/open_catalog.c index 242709db73..46c444d259 100644 --- a/catgets/open_catalog.c +++ b/catgets/open_catalog.c @@ -49,7 +49,7 @@ __open_catalog (const char *cat_name, const char *nlspath, const char *env_var, char *buf = NULL; if (strchr (cat_name, '/') != NULL || nlspath == NULL) - fd = __open_nocancel (cat_name, O_RDONLY); + fd = __open_nocancel (cat_name, O_RDONLY | O_CLOEXEC); else { const char *run_nlspath = nlspath; @@ -177,7 +177,7 @@ __open_catalog (const char *cat_name, const char *nlspath, const char *env_var, if (bufact != 0) { - fd = __open_nocancel (buf, O_RDONLY); + fd = __open_nocancel (buf, O_RDONLY | O_CLOEXEC); if (fd >= 0) break; } |