From: Maximilian Krüger Date: Wed, 11 Nov 2020 10:21:30 +0000 (+0100) Subject: Use O_CLOEXEC in sysconf [BZ #26791] X-Git-Tag: glibc-2.33~317 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d2d714b9fc02e4710d6dc769d8ec2c9dab0eb69a;p=thirdparty%2Fglibc.git Use O_CLOEXEC in sysconf [BZ #26791] If sysconf is used in multithreaded processes, various filedescriptors may leak due to missing O_CLOEXEC. This commit adds the flag. --- diff --git a/sysdeps/unix/sysv/linux/sysconf.c b/sysdeps/unix/sysv/linux/sysconf.c index 7958a74164e..9c5a4cb1a4d 100644 --- a/sysdeps/unix/sysv/linux/sysconf.c +++ b/sysdeps/unix/sysv/linux/sysconf.c @@ -81,7 +81,7 @@ __sysconf (int name) if (procfname != NULL) { - int fd = __open_nocancel (procfname, O_RDONLY); + int fd = __open_nocancel (procfname, O_RDONLY | O_CLOEXEC); if (fd != -1) { /* This is more than enough, the file contains a single integer. */