public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] libc_fatal: Add comment regarding alloca usage.
@ 2023-06-20 18:41 Joe Simmons-Talbott
  2023-07-05 15:16 ` Joe Simmons-Talbott
  0 siblings, 1 reply; 2+ messages in thread
From: Joe Simmons-Talbott @ 2023-06-20 18:41 UTC (permalink / raw)
  To: libc-alpha; +Cc: Joe Simmons-Talbott

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.
---
 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


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] libc_fatal: Add comment regarding alloca usage.
  2023-06-20 18:41 [PATCH] libc_fatal: Add comment regarding alloca usage Joe Simmons-Talbott
@ 2023-07-05 15:16 ` Joe Simmons-Talbott
  0 siblings, 0 replies; 2+ messages in thread
From: Joe Simmons-Talbott @ 2023-07-05 15:16 UTC (permalink / raw)
  To: libc-alpha

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
> 


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-07-05 15:16 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-20 18:41 [PATCH] libc_fatal: Add comment regarding alloca usage Joe Simmons-Talbott
2023-07-05 15:16 ` Joe Simmons-Talbott

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).