From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=MAILING_LIST_MULTI, RCVD_IN_MSPIKE_H2 autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 24310 invoked from network); 2 Aug 2022 11:32:24 -0000 Received: from second.openwall.net (193.110.157.125) by inbox.vuxu.org with ESMTPUTF8; 2 Aug 2022 11:32:24 -0000 Received: (qmail 4079 invoked by uid 550); 2 Aug 2022 11:29:53 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Reply-To: musl@lists.openwall.com Received: (qmail 3994 invoked from network); 2 Aug 2022 11:29:53 -0000 From: Tudor Cretu To: musl@lists.openwall.com Cc: Tudor Cretu Date: Tue, 2 Aug 2022 12:30:36 +0100 Message-Id: <20220802113036.302819-1-tudor.cretu@arm.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [musl] [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 #include #include #include @@ -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