-
Notifications
You must be signed in to change notification settings - Fork 141
Open
Milestone
Description
This code effectively accesses the data at i
and at i+1
:
Lines 257 to 261 in de8ae5a
if (new_p.flags & PICOBIN_PARTITION_FLAGS_HAS_ID_BITS) { | |
uint32_t low = data[i++]; | |
uint32_t high = data[i++]; | |
new_p.id = (uint64_t)low | ((uint64_t)high << 32); | |
} |
However, the code does not ensure that data[1]
will be valid:
Lines 237 to 242 in de8ae5a
std::vector<uint32_t> data; | |
for (unsigned int i=2; i < size; i++) { | |
data.push_back(*it++); | |
} | |
size_t i=0; | |
while (i < data.size()) { |
From https://en.cppreference.com/w/cpp/container/vector/operator_at:
No bounds checking is performed.
Therefore, no guarantee that this will throw an exception (which might be expected), and as a result, clearly getting into undefined behavior.....
Metadata
Metadata
Assignees
Labels
No labels