public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Joe Simmons-Talbott <josimmon@redhat.com>
To: libc-alpha@sourceware.org
Subject: Re: [PATCH] libc_fatal: Add comment regarding alloca usage.
Date: Wed, 5 Jul 2023 11:16:30 -0400	[thread overview]
Message-ID: <20230705151630.GY6392@oak> (raw)
In-Reply-To: <20230620184154.3804141-1-josimmon@redhat.com>

On Tue, Jun 20, 2023 at 02:41:54PM -0400, Joe Simmons-Talbott wrote:
> Since __libc_message is only used in a few places and always with a
> const char * format string and a small fixed-sized struct the usage of
> alloca here is safe.  Add a comment explaining this for both alloca
> usages.

Ping.

Thanks,
Joe
> ---
>  sysdeps/posix/libc_fatal.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/sysdeps/posix/libc_fatal.c b/sysdeps/posix/libc_fatal.c
> index 70edcc10c1..caa01bcbf6 100644
> --- a/sysdeps/posix/libc_fatal.c
> +++ b/sysdeps/posix/libc_fatal.c
> @@ -100,6 +100,9 @@ __libc_message (const char *fmt, ...)
>  	  cp = next;
>  	}
>  
> +      /* alloca is safe here since the current usage of __libc_message uses
> +         relatively short const char * format strings and a small fixed size
> +         struct. */
>        struct str_list *newp = alloca (sizeof (struct str_list));
>        newp->str = str;
>        newp->len = len;
> @@ -110,6 +113,9 @@ __libc_message (const char *fmt, ...)
>  
>    if (nlist > 0)
>      {
> +      /* alloca is safe here since the current usage of __libc_message uses
> +         relatively short const char * format strings and a small fixed size
> +         struct. */
>        struct iovec *iov = alloca (nlist * sizeof (struct iovec));
>        ssize_t total = 0;
>  
> -- 
> 2.39.2
> 


      reply	other threads:[~2023-07-05 15:16 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-20 18:41 Joe Simmons-Talbott
2023-07-05 15:16 ` Joe Simmons-Talbott [this message]

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=20230705151630.GY6392@oak \
    --to=josimmon@redhat.com \
    --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).