File tree Expand file tree Collapse file tree 1 file changed +9
-0
lines changed
ddtrace/internal/datadog/profiling/stack_v2/echion/echion Expand file tree Collapse file tree 1 file changed +9
-0
lines changed Original file line number Diff line number Diff line change 1818#include < echion/errors.h>
1919#include < echion/vm.h>
2020
21+ const constexpr size_t MAX_CHUNK_SIZE = 256 * 1024 ; // 256KB
22+
2123// ----------------------------------------------------------------------------
2224class StackChunk
2325{
@@ -45,6 +47,13 @@ StackChunk::update(_PyStackChunk* chunk_addr)
4547 return ErrorKind::StackChunkError;
4648 }
4749
50+ // It's possible that the memory we read is corrupted/not valid anymore and the
51+ // chunk.size is not meaningful. Weed out those cases here to make sure we don't
52+ // try to allocate absurd amounts of memory.
53+ if (chunk.size > MAX_CHUNK_SIZE) {
54+ return ErrorKind::StackChunkError;
55+ }
56+
4857 origin = chunk_addr;
4958 // if data_capacity is not enough, reallocate.
5059 if (chunk.size > data_capacity) {
You can’t perform that action at this time.
0 commit comments