[PATCH] tests/backtrace.c (frame_callback): Error on seeing more than 16 frames.

Mark Wielaard mjw at redhat.com
Sun Jun 15 09:37:44 UTC 2014


Don't fill up the test logs with obviously bogus frames.

Signed-off-by: Mark Wielaard <mjw at redhat.com>
---
 tests/ChangeLog   | 4 ++++
 tests/backtrace.c | 7 +++++++
 2 files changed, 11 insertions(+)

diff --git a/tests/ChangeLog b/tests/ChangeLog
index cd8a8e7..5fa8b15 100644
--- a/tests/ChangeLog
+++ b/tests/ChangeLog
@@ -1,3 +1,7 @@
+2014-06-15  Mark Wielaard  <mjw at redhat.com>
+
+	* backtrace.c (frame_callback): Error on seeing more than 16 frames.
+
 2014-06-11  Mark Wielaard  <mjw at redhat.com>
 
 	* backtrace.c (main): Check that Dwfl was attached by calling
diff --git a/tests/backtrace.c b/tests/backtrace.c
index ce0bd17..aae344c 100644
--- a/tests/backtrace.c
+++ b/tests/backtrace.c
@@ -147,6 +147,13 @@ frame_callback (Dwfl_Frame *state, void *frame_arg)
   int *framenop = frame_arg;
   Dwarf_Addr pc;
   bool isactivation;
+
+  if (*framenop > 16)
+    {
+      error (0, 0, "Too many frames: %d\n", *framenop);
+      return DWARF_CB_ABORT;
+    }
+
   if (! dwfl_frame_pc (state, &pc, &isactivation))
     {
       error (0, 0, "%s", dwfl_errmsg (-1));
-- 
1.9.3



More information about the elfutils-devel mailing list