[PATCH] resolv: Get rid of alloca usage.
Joe Simmons-Talbott
josimmon@redhat.com
Fri Sep 22 14:24:54 GMT 2023
On Thu, Sep 21, 2023 at 07:36:08PM +0200, Andreas Schwab wrote:
> On Sep 21 2023, Joe Simmons-Talbott wrote:
>
> > diff --git a/resolv/nss_dns/dns-network.c b/resolv/nss_dns/dns-network.c
> > index 1e6511a4f4..b67542c078 100644
> > --- a/resolv/nss_dns/dns-network.c
> > +++ b/resolv/nss_dns/dns-network.c
> > @@ -116,6 +116,7 @@ _nss_dns_getnetbyname_r (const char *name, struct netent *result,
> > querybuf *orig_net_buffer;
> > int anslen;
> > enum nss_status status;
> > + char buf[1024];
> >
> > struct resolv_context *ctx = __resolv_context_get ();
> > if (ctx == NULL)
> > @@ -125,7 +126,7 @@ _nss_dns_getnetbyname_r (const char *name, struct netent *result,
> > return NSS_STATUS_UNAVAIL;
> > }
> >
> > - net_buffer.buf = orig_net_buffer = (querybuf *) alloca (1024);
> > + net_buffer.buf = orig_net_buffer = (querybuf *) &buf;
>
> The buffer should be suitably aligned for querybuf. Since buf is an
> array, it should not get an address-of operator.
>
I've posted a v2 which hopefully addresses this.
Thanks,
Joe
More information about the Libc-alpha
mailing list