]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Use O_CLOEXEC in sysconf [BZ #26791]
authorMaximilian Krüger <max@maxfragg.de>
Wed, 11 Nov 2020 10:21:30 +0000 (11:21 +0100)
committerArjun Shankar <arjun@redhat.com>
Wed, 11 Nov 2020 11:15:21 +0000 (12:15 +0100)
If sysconf is used in multithreaded processes, various filedescriptors
may leak due to missing O_CLOEXEC.  This commit adds the flag.

sysdeps/unix/sysv/linux/sysconf.c

index 7958a74164e9214ead93aac0d9cc58c762a48c6d..9c5a4cb1a4d0e022493d35b119ec197a8f2b60ae 100644 (file)
@@ -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.  */