This is the mail archive of the glibc-bugs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libc/19505] New: Unwanted validity of the file descriptor in posix_spawn_file_actions_add{open,close,dup2} with unlimited file descriptor


https://sourceware.org/bugzilla/show_bug.cgi?id=19505

            Bug ID: 19505
           Summary: Unwanted validity of the file descriptor in
                    posix_spawn_file_actions_add{open,close,dup2} with
                    unlimited file descriptor
           Product: glibc
           Version: unspecified
            Status: NEW
          Severity: normal
          Priority: P2
         Component: libc
          Assignee: unassigned at sourceware dot org
          Reporter: obache at wizdas dot com
                CC: drepper.fsp at gmail dot com
  Target Milestone: ---

In functions "posix_spawn_file_actions_add{open,close,dup2}" implemented in
posix/spawn_function_add{open,close,dup2}.c, following checks exist:

   int maxfd = __sysconf (_SC_OPEN_MAX);

   if (fd < 0 || fd >= maxfd)
     return EBADF;

But generally, "sysconf" will return "-1" if specified resource is unlimited.
So with unlimited file descriptor number situation, such functions always rise
EBADF even if passed "fd" is valid.

I can confirm it on GNU/Hurd with following, set it as maximum allowed value.

                struct rlimit rl;
                if (getrlimit(RLIMIT_NOFILE, &rl) != -1 &&
                    rl.rlim_cur != rl.rlim_max) {
                        rl.rlim_cur = rl.rlim_max;
                        (void)setrlimit(RLIMIT_NOFILE, &rl);
                }

-- 
You are receiving this mail because:
You are on the CC list for the bug.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]