This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
[PATCH] getauxval: fix crash on systems without HAVE_AUX_VECTOR
- From: Samuel Thibault <samuel dot thibault at ens-lyon dot org>
- To: GNU C Library <libc-alpha at sourceware dot org>
- Cc: bug-hurd at gnu dot org
- Date: Sat, 2 Apr 2016 12:57:16 +0200
- Subject: [PATCH] getauxval: fix crash on systems without HAVE_AUX_VECTOR
- Authentication-results: sourceware.org; auth=none
Systems without HAVE_AUX_VECTOR have GLRO(dl_auxv) == NULL, and
getauxval would thus crash.
* misc/getauxval.c (__getauxval): Check for GLRO(dl_auxv) != NULL before
looping through the list.
diff --git a/misc/getauxval.c b/misc/getauxval.c
index e48f40f..7ba0598 100644
--- 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;
__set_errno (ENOENT);
return 0;