This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] getauxval: fix crash on systems without HAVE_AUX_VECTOR


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;


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]