[PATCH v3] resolv/nss_dns/dns-host: Get rid of alloca.
Joe Simmons-Talbott
josimmon@redhat.com
Mon Aug 14 15:01:44 GMT 2023
On Mon, Aug 14, 2023 at 10:28:07AM -0400, Siddhesh Poyarekar wrote:
> On 2023-08-14 10:23, Andreas Schwab via Libc-alpha wrote:
> > On Aug 14 2023, Joe Simmons-Talbott via Libc-alpha wrote:
> >
> > > diff --git a/resolv/nss_dns/dns-host.c b/resolv/nss_dns/dns-host.c
> > > index 1d60c51f5e..160a017d42 100644
> > > --- a/resolv/nss_dns/dns-host.c
> > > +++ b/resolv/nss_dns/dns-host.c
> > > @@ -395,8 +395,8 @@ _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);
> > > + char tmp[NS_MAXDNAME];
> > > + const char *cp = __res_context_hostalias (ctx, name, tmp, sizeof (tmp));
> > > if (cp != NULL)
> > > name = cp;
> > > }
> >
> > We don't tolerate undefined behaviour in glibc.
> >
>
> Ah, sorry I hadn't noticed that cp escapes that scope. Joe, your v2 is
> correct.
I went ahead and posted a v4 patch moving tmp back up one scope level
[1]
[1] https://sourceware.org/pipermail/libc-alpha/2023-August/150906.html
Thanks,
Joe
More information about the Libc-alpha
mailing list