|
Message-Id: <20220802113036.302819-1-tudor.cretu@arm.com> Date: Tue, 2 Aug 2022 12:30:36 +0100 From: Tudor Cretu <tudor.cretu@....com> To: musl@...ts.openwall.com Cc: Tudor Cretu <tudor.cretu@....com> Subject: [PATCH] clone: Return EINVAL for null stack This change aligns the clone wrapper with the man page. If the stack is null, clone sets errno to EINVAL, instead of throwing a segmentation fault. --- src/linux/clone.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/linux/clone.c b/src/linux/clone.c index 8c1af7d3..43a6803b 100644 --- a/src/linux/clone.c +++ b/src/linux/clone.c @@ -1,4 +1,5 @@ #define _GNU_SOURCE +#include <errno.h> #include <stdarg.h> #include <unistd.h> #include <sched.h> @@ -11,6 +12,10 @@ int clone(int (*func)(void *), void *stack, int flags, void *arg, ...) pid_t *ptid, *ctid; void *tls; + if (!stack) { + return __syscall_ret(-EINVAL); + } + va_start(ap, arg); ptid = va_arg(ap, pid_t *); tls = va_arg(ap, void *); -- 2.25.1
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.