From: Joe Simmons-Talbott <josimmon@redhat.com>
To: libc-alpha@sourceware.org
Cc: Joe Simmons-Talbott <josimmon@redhat.com>
Subject: [PATCH v2] resolv/nss_dns/dns-host: Get rid of alloca.
Date: Thu, 10 Aug 2023 11:57:22 -0400 [thread overview]
Message-ID: <20230810155738.2645097-1-josimmon@redhat.com> (raw)
Since the alloca is a small constant size use an array instead.
---
Changes to v1:
* Use sizeof (tmp) rather than NS_MAXDNAME
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;
}
--
2.39.2
next reply other threads:[~2023-08-10 15:57 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-10 15:57 Joe Simmons-Talbott [this message]
2023-08-11 17:38 ` Siddhesh Poyarekar
2023-08-14 14:14 ` Joe Simmons-Talbott
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=20230810155738.2645097-1-josimmon@redhat.com \
--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).