In dalvik.cc::GetString, break loop if we reach an invalid address.#156
Merged
copybara-service[bot] merged 3 commits intoFeb 2, 2026
Merged
Conversation
In GetString there is a call to IDA's `get_byte` in a loop till a null is reached. Given that `get_byte` returns 0xFF if an invalid address is requested, there is chance for an infinite loop here. To fix that, add a break if `get_byte` returns 0xFF.
Contributor
Author
|
@cblichmann Could you please review this PR? |
cblichmann
reviewed
Jan 9, 2026
| for (;;) { | ||
| uint8_t b = get_byte(static_cast<ea_t>(ea++)); | ||
| if (b == 0) { | ||
| if (b == 0 || b == 0xFF) { |
Member
There was a problem hiding this comment.
Should probably use is_mapped() from bytes.hpp instead
Member
Let's ignore the Copybara failure, I'll deal with that before merging. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I attempted to export a fairly large idb of a jar file and it was taking forever, as well as filling my RAM and swap to 100%, at which point the Linux kernel decided to terminate IDA Pro.
I started digging around the code and realized that either an invalid address was getting sent to
GetString, or I guess it was hitting an invalid address due to a non-null terminated string. In either case, it was causing an infinite loop.It turns out that if we pass an invalid address to
get_byte, it returns 0xFF, so I added that to the break condition which allowed me to export my database.I'm not sure this is the best fix because I'm getting the following error when trying to load the BinExport into python:
IPython traceback
It's not too bad because you can just:
But it's not ideal. Let me know if there is a better way to fix this. Perhaps use a different function from the IDA API,
get_bytes?