Skip to content

Commit 66b6cd4

Browse files
authored
fix(SentryBacktrace): Guard stack frame pointer dereference (#4268)
1 parent df2835d commit 66b6cd4

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
- Session replay not redacting buttons and other non UILabel texts (#4277)
1313
- Rarely reporting too long frame delays (#4278) by fixing a race condition in the frames tracking logic.
1414
- Crash deserializing empty envelope length>0 (#4281]
15+
- Guard dereferencing of stack frame pointer in SentryBacktrace ([#4268](https://github.com/getsentry/sentry-cocoa/pull/4268))
1516

1617
## 8.33.0
1718

Sources/Sentry/SentryBacktrace.cpp

+9-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,12 @@
1111
# include "SentryThreadMetadataCache.hpp"
1212
# include "SentryThreadState.hpp"
1313
# include "SentryTime.h"
14-
14+
extern "C" {
15+
# define restrict
16+
/** Allow importing C99 headers that use the restrict keyword, which isn't valid in C++ */
17+
# include "SentryCrashMemory.h"
18+
# undef restrict
19+
}
1520
# include <cassert>
1621
# include <cstring>
1722
# include <dispatch/dispatch.h>
@@ -81,6 +86,9 @@ namespace profiling {
8186
bool reachedEndOfStack = false;
8287
while (depth < maxDepth) {
8388
const auto frame = reinterpret_cast<StackFrame *>(current);
89+
if (!sentrycrashmem_isMemoryReadable(frame, sizeof(StackFrame))) {
90+
break;
91+
}
8492
if (LIKELY(skip == 0)) {
8593
addresses[depth++] = getPreviousInstructionAddress(frame->returnAddress);
8694
} else {

0 commit comments

Comments
 (0)