public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: "Cristian Rodríguez" <crrodriguez@opensuse.org>
To: libc-alpha@sourceware.org
Subject: [PATCH 2/2] linux: posix_spawn: return EINVAL on argc < 1
Date: Fri, 28 Jan 2022 13:39:37 +0000	[thread overview]
Message-ID: <20220128133937.9555-1-crrodriguez@opensuse.org> (raw)

posix_spawn allows argc < 1 but the specification says that
"The value in argv[0] should point to a filename string.."
So there must be at least one non-null argument.

Signed-off-by: Cristian Rodríguez <crrodriguez@opensuse.org>
---
 sysdeps/unix/sysv/linux/spawni.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/sysdeps/unix/sysv/linux/spawni.c b/sysdeps/unix/sysv/linux/spawni.c
index 93359c708b..23617c9165 100644
--- a/sysdeps/unix/sysv/linux/spawni.c
+++ b/sysdeps/unix/sysv/linux/spawni.c
@@ -334,6 +334,11 @@ __spawnix (pid_t * pid, const char *file,
 	errno = E2BIG;
 	return errno;
       }
+    if (argc < 1)
+      {
+	errno = EINVAL;
+	return errno;
+      }
 
   int prot = (PROT_READ | PROT_WRITE
 	     | ((GL (dl_stack_flags) & PF_X) ? PROT_EXEC : 0));
-- 
2.34.1


             reply	other threads:[~2022-01-28 13:48 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-28 13:39 Cristian Rodríguez [this message]
2022-01-28 15:26 ` Cristian Rodríguez
2022-01-28 17:07   ` Adhemerval Zanella
2022-01-28 18:03     ` Joseph Myers
2022-01-28 23:05       ` Adhemerval Zanella
2022-01-28 23:26         ` Joseph Myers
2022-01-28 23:35           ` Cristian Rodríguez
2022-01-28 23:49             ` Joseph Myers
2022-01-29  1:04               ` Cristian Rodríguez
2022-03-23 14:40                 ` Cristian Rodríguez
2022-01-28 19:08     ` Cristian Rodríguez

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=20220128133937.9555-1-crrodriguez@opensuse.org \
    --to=crrodriguez@opensuse.org \
    --cc=libc-alpha@sourceware.org \
    /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.
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 read-only IMAP folder(s) and NNTP newsgroup(s).