about summary refs log tree commit diff
path: root/debug/tst-backtrace5.c
diff options
context:
space:
mode:
authorAndreas Schwab <schwab@suse.de>2020-01-20 17:01:50 +0100
committerAndreas Schwab <schwab@suse.de>2020-01-21 15:26:57 +0100
commitd93769405996dfc11d216ddbe415946617b5a494 (patch)
tree495421ac18939903f2514d2d658b038fcdc26f31 /debug/tst-backtrace5.c
parent8b222fa38700422b4da6731806835f0bbf40920d (diff)
downloadglibc-d93769405996dfc11d216ddbe415946617b5a494.tar.gz
glibc-d93769405996dfc11d216ddbe415946617b5a494.tar.xz
glibc-d93769405996dfc11d216ddbe415946617b5a494.zip
Fix array overflow in backtrace on PowerPC (bug 25423)
When unwinding through a signal frame the backtrace function on PowerPC
didn't check array bounds when storing the frame address.  Fixes commit
d400dcac5e ("PowerPC: fix backtrace to handle signal trampolines").
Diffstat (limited to 'debug/tst-backtrace5.c')
-rw-r--r--debug/tst-backtrace5.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/debug/tst-backtrace5.c b/debug/tst-backtrace5.c
index e7ce410845..b2f46160e7 100644
--- a/debug/tst-backtrace5.c
+++ b/debug/tst-backtrace5.c
@@ -89,6 +89,18 @@ handle_signal (int signum)
       }
   /* Symbol names are not available for static functions, so we do not
      check do_test.  */
+
+  /* Check that backtrace does not return more than what fits in the array
+     (bug 25423).  */
+  for (int j = 0; j < NUM_FUNCTIONS; j++)
+    {
+      n = backtrace (addresses, j);
+      if (n > j)
+	{
+	  FAIL ();
+	  return;
+	}
+    }
 }
 
 NO_INLINE int