Skip to content

Commit 48971fa

Browse files
committed
Fix bug with truncated binaries
Without this you get an infinite loop - this fix was already in get_last_block
1 parent 91173cb commit 48971fa

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

bintool/bintool.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,9 @@ std::vector<std::unique_ptr<block>> get_all_blocks(std::vector<uint8_t> &bin, ui
375375
}
376376
auto offset = next_block_addr - current_bin_start;
377377
std::vector<uint32_t> words = lsb_bytes_to_words(bin.begin() + offset, bin.end());
378+
if (words.front() != PICOBIN_BLOCK_MARKER_START) {
379+
fail(ERROR_UNKNOWN, "Block loop is not valid - no block found at %08x\n", (int)(next_block_addr));
380+
}
378381
words.erase(words.begin());
379382
DEBUG_LOG("Checking block at %x\n", next_block_addr);
380383
DEBUG_LOG("Starts with %x %x %x %x\n", words[0], words[1], words[2], words[3]);

0 commit comments

Comments
 (0)