Skip to content

Commit

Permalink
Early stop on corrupted macho method storage ##bin
Browse files Browse the repository at this point in the history
* This situation should be catched earlier
* But it's easier to debug this way and loads faster
  • Loading branch information
trufae authored Jul 9, 2024
1 parent 5a2a903 commit e4ea09f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions libr/bin/bfilter.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ R_API char *r_bin_filter_name(RBinFile *bf, HtSU *db, ut64 vaddr, const char *na
return resname;
}

// R2_600 - return bool for success or not
R_API void r_bin_filter_sym(RBinFile *bf, HtPP *ht, ut64 vaddr, RBinSymbol *sym) {
R_RETURN_IF_FAIL (ht && sym && sym->name);
const char *name = r_bin_name_tostring2 (sym->name, 'o');
Expand Down
12 changes: 10 additions & 2 deletions libr/bin/bobj.c
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,8 @@ R_IPI RBinObject *r_bin_object_new(RBinFile *bf, RBinPlugin *plugin, ut64 basead
return bo;
}

static void filter_classes(RBinFile *bf, RList *list) {
static bool filter_classes(RBinFile *bf, RList *list) {
bool rc = true;
HtSU *db = ht_su_new0 ();
HtPP *ht = ht_pp_new0 ();
RListIter *iter, *iter2;
Expand All @@ -269,16 +270,23 @@ static void filter_classes(RBinFile *bf, RList *list) {
char *fname = r_bin_filter_name (bf, db, cls->index, kname);
if (R_STR_ISEMPTY (fname)) {
R_LOG_INFO ("Corrupted class storage with nameless classes");
rc = false;
break;
}
r_bin_name_update (cls->name, fname);
free (fname);
r_list_foreach (cls->methods, iter2, sym) {
r_bin_filter_sym (bf, ht, sym->vaddr, sym);
if (R_LIKELY (sym->name)) {
r_bin_filter_sym (bf, ht, sym->vaddr, sym);
} else {
R_LOG_INFO ("Unnamed method. Assuming corrupted storage");
break;
}
}
}
ht_su_free (db);
ht_pp_free (ht);
return rc;
}

static RRBTree *list2rbtree(RList *relocs) {
Expand Down

0 comments on commit e4ea09f

Please sign in to comment.