This code effectively accesses the data at i and at i+1:
|
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:
|
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.....
This code effectively accesses the data at
iand ati+1:picotool/bintool/metadata.h
Lines 257 to 261 in de8ae5a
However, the code does not ensure that
data[1]will be valid:picotool/bintool/metadata.h
Lines 237 to 242 in de8ae5a
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.....