upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/runtime/src
diff options
context:
space:
mode:
authorxroneyaa <202318392+xroneyaa@users.noreply.github.com>2026-11-24 11:09:18 +0500
committerxroneyaa <202318392+xroneyaa@users.noreply.github.com>2026-11-24 11:09:18 +0500
commit36e9f9fce9bc33a4074ee6a37c3379a9fb5864cb (patch)
tree68d21e089c80d5ff7fec65641308a3be795c966d /runtime/src
parent8f481cf16f261c7f37458aeb45e8f4e19994146d (diff)
xdxr_descs: require complete 16-byte StreamRecords in find_stream_record
Diffstat (limited to 'runtime/src')
-rw-r--r--runtime/src/xdxr_descs.h7
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.
101inline const StreamRecord* find_stream_record(const StreamDesc& desc, uint32_t type) { 101inline 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)