diff options
| author | ubiquitarianism <283527159+ubiquitarianism@users.noreply.github.com> | 2026-11-24 11:11:50 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-11-24 11:11:50 -0500 |
| commit | 42d705c85bdb4a8450c2e576bca7bee8d6770c93 (patch) | |
| tree | f32f51b6847814ec90a92c4a14e33e7135072686 /runtime/src | |
| parent | 1209391777a86e5aaee554cd228542b56ce8e42c (diff) | |
| parent | 36e9f9fce9bc33a4074ee6a37c3379a9fb5864cb (diff) | |
Merge pull request #484 from xroneyaa/fix/xdxr-stream-record-bounds
XDXR-STREAM-RECORD-BOUNDS: require complete 16-byte StreamRecords in find_stream_record
Diffstat (limited to 'runtime/src')
| -rw-r--r-- | runtime/src/xdxr_descs.h | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/runtime/src/xdxr_descs.h b/runtime/src/xdxr_descs.h index b44ce0372..3798b0fe7 100644 --- a/runtime/src/xdxr_descs.h +++ b/runtime/src/xdxr_descs.h | |||
| @@ -99,12 +99,11 @@ constexpr uint32_t kPostbuildInfoOfflineStatistics = 0x10; | |||
| 99 | // The record a setting is read from, the way the DLL finds it: the first record of `type` from the start, stepping | 99 | // The record a setting is read from, the way the DLL finds it: the first record of `type` from the start, stepping |
| 100 | // over types 0, 1 and 2, and stopping at any other type. Null when there is none. | 100 | // over types 0, 1 and 2, and stopping at any other type. Null when there is none. |
| 101 | inline const StreamRecord* find_stream_record(const StreamDesc& desc, uint32_t type) { | 101 | inline const StreamRecord* find_stream_record(const StreamDesc& desc, uint32_t type) { |
| 102 | if (desc.size_in_bytes == 0 || desc.stream == nullptr) | 102 | if (desc.size_in_bytes < sizeof(StreamRecord) || desc.stream == nullptr) |
| 103 | return nullptr; | 103 | return nullptr; |
| 104 | const auto* record = static_cast<const StreamRecord*>(desc.stream); | 104 | const auto* record = static_cast<const StreamRecord*>(desc.stream); |
| 105 | const auto* end = reinterpret_cast<const StreamRecord*>(static_cast<const uint8_t*>(desc.stream) + | 105 | const uint64_t count = desc.size_in_bytes / sizeof(StreamRecord); |
| 106 | desc.size_in_bytes); | 106 | for (uint64_t i = 0; i < count; ++i, ++record) { |
| 107 | for (; record < end; ++record) { | ||
| 108 | if (record->type == type) | 107 | if (record->type == type) |
| 109 | return record; | 108 | return record; |
| 110 | if (record->type > 2) | 109 | if (record->type > 2) |