mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Bruno Haible <bruno@clisp.org>
To: musl@lists.openwall.com
Subject: [musl] insufficient checking in posix_spawn_file_actions_add{open,dup2}
Date: Mon, 25 Jan 2021 09:31:50 +0100	[thread overview]
Message-ID: <3521697.b4TYcCAa2N@omega> (raw)

Hi,

POSIX [1][2] says about the functions
  posix_spawn_file_actions_addopen
  posix_spawn_file_actions_adddup2

The function "shall fail if:
  [EBADF]
      The value specified by fildes is negative or greater than or equal to {OPEN_MAX}."

However, in musl libc 1.2.2, these two test programs exit with status 2:
========================================================================
#include <spawn.h>
#include <fcntl.h>
int main ()
{
  posix_spawn_file_actions_t actions;
  if (posix_spawn_file_actions_init (&actions) != 0)
    return 1;
  if (posix_spawn_file_actions_addopen (&actions, 10000000, "foo", 0, O_RDONLY)
      == 0)
    return 2;
  return 0;
}
========================================================================
#include <spawn.h>
int main ()
{
  posix_spawn_file_actions_t actions;
  if (posix_spawn_file_actions_init (&actions) != 0)
    return 1;
  if (posix_spawn_file_actions_adddup2 (&actions, 10000000, 2) == 0)
    return 2;
  return 0;
}
========================================================================

sysconf (_SC_OPEN_MAX) is 1024, on that system.

Best regards,

      Bruno

[1] https://pubs.opengroup.org/onlinepubs/9699919799/functions/posix_spawn_file_actions_addopen.html
[2] https://pubs.opengroup.org/onlinepubs/9699919799/functions/posix_spawn_file_actions_adddup2.html


             reply	other threads:[~2021-01-25  8:32 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-25  8:31 Bruno Haible [this message]
2021-01-25  8:40 ` [musl] insufficient checking in posix_spawn_file_actions_addclose Bruno Haible
2021-01-25 14:42 ` [musl] insufficient checking in posix_spawn_file_actions_add{open,dup2} Rich Felker
2021-01-25 16:07   ` Bruno Haible
2021-01-25 16:15     ` Rich Felker
2021-01-25 17:58       ` Bruno Haible
2021-01-25 19:33       ` Alexey Izbyshev
2021-01-25 19:37       ` Markus Wichmann
2021-01-25 19:48         ` Florian Weimer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3521697.b4TYcCAa2N@omega \
    --to=bruno@clisp.org \
    --cc=musl@lists.openwall.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).