Skip to content

Commit

Permalink
Fix bug with truncated binaries
Browse files Browse the repository at this point in the history
Without this you get an infinite loop - this fix was already in get_last_block
  • Loading branch information
will-v-pi committed Feb 21, 2025
1 parent 91173cb commit 48971fa
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions bintool/bintool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,9 @@ std::vector<std::unique_ptr<block>> get_all_blocks(std::vector<uint8_t> &bin, ui
}
auto offset = next_block_addr - current_bin_start;
std::vector<uint32_t> words = lsb_bytes_to_words(bin.begin() + offset, bin.end());
if (words.front() != PICOBIN_BLOCK_MARKER_START) {
fail(ERROR_UNKNOWN, "Block loop is not valid - no block found at %08x\n", (int)(next_block_addr));
}
words.erase(words.begin());
DEBUG_LOG("Checking block at %x\n", next_block_addr);
DEBUG_LOG("Starts with %x %x %x %x\n", words[0], words[1], words[2], words[3]);
Expand Down

0 comments on commit 48971fa

Please sign in to comment.