Re: Fw: [PATCH] Improve execl* functions

Corinna Vinschen <[email protected]>
Newsgroups gmane.comp.lib.newlib
Message-ID <[email protected]>
Hi Federico,

On Jan 31 17:42, Federico Terraneo wrote:
> Hi,
> updated patch 0002.

Both patches pushed.


Thanks,
Corinna


> From a13bf0a67ab85138cd31a6673494f30284fb9b60 Mon Sep 17 00:00:00 2001
> From: Terraneo Federico <[email protected]>
> Date: Tue, 28 Jan 2025 17:19:18 +0100
> Subject: [PATCH 2/2] Lift 256 arg limit in execl, execle and execlp, add
>  --enable-newlib-use-malloc-in-execl option
> 
> The previous version of these functions allocated a 256 entry array and copied
> arguments in that array with no bound checking. That implementation always
> occupied 1024 bytes of stack for the array even in the common case in which the
> number of passed arguments is far less than 256, risking stack overflows in
> environments with small stacks, and caused a stack buffer overflow if called
> with more than 256 arguments.
> 
> The improved implementation counts the actual number of passed arguments and
> allocates a suitable buffer. The default implementation uses alloca to allocate
> the buffer to satisfy the POSIX.1-2008 requirement that execl and execle should
> be callable from signal handlers, but it is possible to override this behavior
> and use malloc for targets where the risk of stack overflow due to unbounded
> stack allocations is a more pressing requirement than the corner case of
> allowing execl calls from signal handlers.
> ---
>  newlib/README              |  8 ++++++++
>  newlib/configure           | 19 +++++++++++++++++++
>  newlib/configure.ac        | 13 +++++++++++++
>  newlib/libc/posix/execl.c  | 36 ++++++++++++++++++++++++++++++++++--
>  newlib/libc/posix/execle.c | 36 ++++++++++++++++++++++++++++++++++--
>  newlib/libc/posix/execlp.c | 31 +++++++++++++++++++++++++++++--
>  newlib/newlib.hin          |  3 +++
>  7 files changed, 140 insertions(+), 6 deletions(-)
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.