public inbox for glibc-cvs@sourceware.org
help / color / mirror / Atom feed
* [glibc] resolv/nss_dns/dns-host: Get rid of alloca.
@ 2023-08-14 20:51 Joe Simmons-Talbott
  0 siblings, 0 replies; only message in thread
From: Joe Simmons-Talbott @ 2023-08-14 20:51 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=648b832600e94c09e3cee2fa6d3c3684687505e4

commit 648b832600e94c09e3cee2fa6d3c3684687505e4
Author: Joe Simmons-Talbott <josimmon@redhat.com>
Date:   Mon Aug 14 20:50:40 2023 +0000

    resolv/nss_dns/dns-host: Get rid of alloca.
    
    Since the alloca is a small constant size use an array instead.
    
    Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>

Diff:
---
 resolv/nss_dns/dns-host.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/resolv/nss_dns/dns-host.c b/resolv/nss_dns/dns-host.c
index 1d60c51f5e..c8b77bbc35 100644
--- a/resolv/nss_dns/dns-host.c
+++ b/resolv/nss_dns/dns-host.c
@@ -378,6 +378,7 @@ _nss_dns_gethostbyname4_r (const char *name, struct gaih_addrtuple **pat,
 			   int *herrnop, int32_t *ttlp)
 {
   enum nss_status status = check_name (name, herrnop);
+  char tmp[NS_MAXDNAME];
   if (status != NSS_STATUS_SUCCESS)
     return status;
   struct resolv_context *ctx = __resolv_context_get ();
@@ -395,8 +396,7 @@ _nss_dns_gethostbyname4_r (const char *name, struct gaih_addrtuple **pat,
    */
   if (strchr (name, '.') == NULL)
     {
-      char *tmp = alloca (NS_MAXDNAME);
-      const char *cp = __res_context_hostalias (ctx, name, tmp, NS_MAXDNAME);
+      const char *cp = __res_context_hostalias (ctx, name, tmp, sizeof (tmp));
       if (cp != NULL)
 	name = cp;
     }

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-08-14 20:51 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-14 20:51 [glibc] resolv/nss_dns/dns-host: Get rid of alloca 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).