aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/google_breakpad/processor/stackwalker.h8
-rw-r--r--src/processor/stackwalker.cc7
2 files changed, 13 insertions, 2 deletions
diff --git a/src/google_breakpad/processor/stackwalker.h b/src/google_breakpad/processor/stackwalker.h
index 3abcee75..36d721d1 100644
--- a/src/google_breakpad/processor/stackwalker.h
+++ b/src/google_breakpad/processor/stackwalker.h
@@ -48,7 +48,6 @@
namespace google_breakpad {
class CallStack;
-class CodeModule;
class CodeModules;
class MemoryRegion;
class MinidumpContext;
@@ -80,6 +79,9 @@ class Stackwalker {
SymbolSupplier *supplier,
SourceLineResolverInterface *resolver);
+ static void set_max_frames(u_int32_t max_frames) { max_frames_ = max_frames; }
+ static u_int32_t max_frames() { return max_frames_; }
+
protected:
// system_info identifies the operating system, NULL or empty if unknown.
// memory identifies a MemoryRegion that provides the stack memory
@@ -146,6 +148,10 @@ class Stackwalker {
// this in order to avoid repeatedly looking them up again within
// one minidump.
set<std::string> no_symbol_modules_;
+
+ // The maximum number of frames Stackwalker will walk through.
+ // This defaults to 1024 to prevent infinite loops.
+ static u_int32_t max_frames_;
};
diff --git a/src/processor/stackwalker.cc b/src/processor/stackwalker.cc
index 8552e2f3..39eb65ec 100644
--- a/src/processor/stackwalker.cc
+++ b/src/processor/stackwalker.cc
@@ -55,6 +55,7 @@
namespace google_breakpad {
+u_int32_t Stackwalker::max_frames_ = 1024;
Stackwalker::Stackwalker(const SystemInfo *system_info,
MemoryRegion *memory,
@@ -120,6 +121,10 @@ bool Stackwalker::Walk(CallStack *stack) {
// Add the frame to the call stack. Relinquish the ownership claim
// over the frame, because the stack now owns it.
stack->frames_.push_back(frame.release());
+ if (stack->frames_.size() > max_frames_) {
+ BPLOG(ERROR) << "The stack is over " << max_frames_ << " frames.";
+ break;
+ }
// Get the next frame and take ownership.
frame.reset(GetCallerFrame(stack));
@@ -166,7 +171,7 @@ Stackwalker* Stackwalker::StackwalkerForCPU(
memory, modules, supplier,
resolver);
break;
-
+
case MD_CONTEXT_SPARC:
cpu_stackwalker = new StackwalkerSPARC(system_info,
context->GetContextSPARC(),