resolv/nss_dns/dns-host: Note the usage of alloca is safe.
Checks
Context |
Check |
Description |
redhat-pt-bot/TryBot-apply_patch |
success
|
Patch applied to master at the time it was sent
|
redhat-pt-bot/TryBot-32bit |
success
|
Build for i686
|
linaro-tcwg-bot/tcwg_glibc_check--master-arm |
success
|
Testing passed
|
linaro-tcwg-bot/tcwg_glibc_check--master-aarch64 |
success
|
Testing passed
|
linaro-tcwg-bot/tcwg_glibc_build--master-arm |
success
|
Testing passed
|
linaro-tcwg-bot/tcwg_glibc_build--master-aarch64 |
success
|
Testing passed
|
redhat-pt-bot/TryBot-still_applies |
warning
|
Patch no longer applies to master
|
Commit Message
Since the size is relatively small and constant add a comment that the
usage of alloca is safe.
---
resolv/nss_dns/dns-host.c | 1 +
1 file changed, 1 insertion(+)
Comments
On Wed, Jul 05, 2023 at 02:58:35PM -0400, Joe Simmons-Talbott wrote:
> Since the size is relatively small and constant add a comment that the
> usage of alloca is safe.
Ping.
Thanks,
Joe
> ---
> resolv/nss_dns/dns-host.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/resolv/nss_dns/dns-host.c b/resolv/nss_dns/dns-host.c
> index 1d60c51f5e..d3aaeec293 100644
> --- a/resolv/nss_dns/dns-host.c
> +++ b/resolv/nss_dns/dns-host.c
> @@ -395,6 +395,7 @@ _nss_dns_gethostbyname4_r (const char *name, struct gaih_addrtuple **pat,
> */
> if (strchr (name, '.') == NULL)
> {
> + /* alloca is safe here since the size is small and constant. */
> char *tmp = alloca (NS_MAXDNAME);
> const char *cp = __res_context_hostalias (ctx, name, tmp, NS_MAXDNAME);
> if (cp != NULL)
> --
> 2.39.2
>
On Jul 05 2023, Joe Simmons-Talbott via Libc-alpha wrote:
> Since the size is relatively small and constant add a comment that the
> usage of alloca is safe.
> ---
> resolv/nss_dns/dns-host.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/resolv/nss_dns/dns-host.c b/resolv/nss_dns/dns-host.c
> index 1d60c51f5e..d3aaeec293 100644
> --- a/resolv/nss_dns/dns-host.c
> +++ b/resolv/nss_dns/dns-host.c
> @@ -395,6 +395,7 @@ _nss_dns_gethostbyname4_r (const char *name, struct gaih_addrtuple **pat,
> */
> if (strchr (name, '.') == NULL)
> {
> + /* alloca is safe here since the size is small and constant. */
> char *tmp = alloca (NS_MAXDNAME);
Since this is a constant allocation, I think it would be better to just
declare it as a regular array in the enclosing block.
On Wed, 2023-07-05 at 14:58 -0400, Joe Simmons-Talbott via Libc-alpha wrote:
> Since the size is relatively small and constant add a comment that the
> usage of alloca is safe.
> ---
> resolv/nss_dns/dns-host.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/resolv/nss_dns/dns-host.c b/resolv/nss_dns/dns-host.c
> index 1d60c51f5e..d3aaeec293 100644
> --- a/resolv/nss_dns/dns-host.c
> +++ b/resolv/nss_dns/dns-host.c
> @@ -395,6 +395,7 @@ _nss_dns_gethostbyname4_r (const char *name, struct gaih_addrtuple **pat,
> */
> if (strchr (name, '.') == NULL)
> {
> + /* alloca is safe here since the size is small and constant. */
> char *tmp = alloca (NS_MAXDNAME);
But then why don't we simply say "char tmp[NS_MAXDNAME];" here?
> const char *cp = __res_context_hostalias (ctx, name, tmp, NS_MAXDNAME);
> if (cp != NULL)
On Thu, Aug 10, 2023 at 10:07:34PM +0800, Xi Ruoyao wrote:
> On Wed, 2023-07-05 at 14:58 -0400, Joe Simmons-Talbott via Libc-alpha wrote:
> > Since the size is relatively small and constant add a comment that the
> > usage of alloca is safe.
> > ---
> > resolv/nss_dns/dns-host.c | 1 +
> > 1 file changed, 1 insertion(+)
> >
> > diff --git a/resolv/nss_dns/dns-host.c b/resolv/nss_dns/dns-host.c
> > index 1d60c51f5e..d3aaeec293 100644
> > --- a/resolv/nss_dns/dns-host.c
> > +++ b/resolv/nss_dns/dns-host.c
> > @@ -395,6 +395,7 @@ _nss_dns_gethostbyname4_r (const char *name, struct gaih_addrtuple **pat,
> > */
> > if (strchr (name, '.') == NULL)
> > {
> > + /* alloca is safe here since the size is small and constant. */
> > char *tmp = alloca (NS_MAXDNAME);
>
> But then why don't we simply say "char tmp[NS_MAXDNAME];" here?
>
Dropped in favor of
https://sourceware.org/pipermail/libc-alpha/2023-August/150819.html
Thanks,
Joe
> > const char *cp = __res_context_hostalias (ctx, name, tmp, NS_MAXDNAME);
> > if (cp != NULL)
>
> --
> Xi Ruoyao <xry111@xry111.site>
> School of Aerospace Science and Technology, Xidian University
>
@@ -395,6 +395,7 @@ _nss_dns_gethostbyname4_r (const char *name, struct gaih_addrtuple **pat,
*/
if (strchr (name, '.') == NULL)
{
+ /* alloca is safe here since the size is small and constant. */
char *tmp = alloca (NS_MAXDNAME);
const char *cp = __res_context_hostalias (ctx, name, tmp, NS_MAXDNAME);
if (cp != NULL)