[PATCH] getauxval: fix crash on systems without HAVE_AUX_VECTOR
Mike Frysinger
vapier@gentoo.org
Sat Apr 2 17:30:00 GMT 2016
On 02 Apr 2016 12:57, Samuel Thibault wrote:
> Systems without HAVE_AUX_VECTOR have GLRO(dl_auxv) == NULL, and
> getauxval would thus crash.
assuming this is for GNU/hurd
> --- a/misc/getauxval.c
> +++ b/misc/getauxval.c
> @@ -30,9 +30,10 @@ __getauxval (unsigned long int type)
> else if (type == AT_HWCAP2)
> return GLRO(dl_hwcap2);
>
> - for (p = GLRO(dl_auxv); p->a_type != AT_NULL; p++)
> - if (p->a_type == type)
> - return p->a_un.a_val;
> + if (GLRO(dl_auxv) != NULL)
> + for (p = GLRO(dl_auxv); p->a_type != AT_NULL; p++)
> + if (p->a_type == type)
> + return p->a_un.a_val;
should this just be under HAVE_AUX_VECTOR ? seems like we shouldn't
even bother defining/exporting dl_auxv at all if it's disabled. then
we wouldn't run into more latent problems like this at run time -- it
would be a build failure.
in looking at other uses of dl_auxv, why isn't _dl_sysdep_start an
issue too ? rtld.c:_dl_start_final always calls that, and that func
always walks GLRO(dl_auxv).
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://sourceware.org/pipermail/libc-alpha/attachments/20160402/f66249df/attachment.sig>
More information about the Libc-alpha
mailing list