IDA plugin: fix result save/load for same-named binaries - #92
Open
xeropresence wants to merge 2 commits into
Open
xeropresence wants to merge 2 commits into
xeropresence wants to merge 2 commits into
Conversation
Diffing two databases with the same basename (e.g. two versions of the same binary in different directories) wrote both .BinExport sidecars to the same path next to the result file, so the secondary overwrote the primary. Loading the result then read the secondary export as both call graphs and reported a hash mismatch against the open IDB. Name the exports <stem>_primary.BinExport / <stem>_secondary.BinExport in that case, following the convention already used by the BinDiff UI (NewDiffImplementation.createUniqueExportFileName). The names flow through CallGraph::GetFilename() into the file.filename column, so save, load and the UI resolve distinct sidecars.
DatabaseReader::Read resolves <dir>/<file.filename>.BinExport per side. If both filenames are equal, one export has necessarily overwritten the other, so fail with an actionable error instead of silently loading the same file for both sides.
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
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.
Problem
Diffing two databases with the same basename (e.g.
v1/app.exe.i64vsv2/app.exe.i64) produces a broken resultfile:
WriteResultscopies both.BinExportsidecars next to the.BinDiffby basename; the secondary overwrites theprimary.
DatabaseReader::Readresolves<dir>/<file.filename>.BinExportper side; with identicalfilenamecolumns, thesecondary export is loaded as both call graphs.
Loading such a result then shows the "original file hash … is different from the primary one in the result file"
warning, and all primary addresses are resolved against the wrong call graph.
Fix
ida/main_plugin.cc(ExportIdbs): when both IDB stems are equal, export as<stem>_primary.BinExport/<stem>_secondary.BinExport— the same convention the Java UI uses(
NewDiffImplementation.createUniqueExportFileName). This flows throughCallGraph::GetFilename()into thefile.filenamecolumn, so save, load, and the UI all resolve distinct sidecars. Non-colliding names are unchanged.database_writer.cc(DatabaseReader::Read): fail with aFailedPreconditionif primary and secondary wouldresolve to the same
.BinExport, instead of silently loading one file twice.Notes
Result files already saved with colliding names cannot be repaired (the primary sidecar is gone); re-diff and save
again.