Skip to content

Commit

Permalink
Fix oobread bug in NE parser ##crash
Browse files Browse the repository at this point in the history
* Reported by @cnitlrt via huntrdev
* BountyID: 02b4b563-b946-4343-9092-38d1c5cd60c9
* Reproducer: neoobread
  • Loading branch information
trufae committed Apr 16, 2022
1 parent a58b8d4 commit 1dd6533
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions libr/bin/format/mach0/coresymbolication.c
Expand Up @@ -274,12 +274,12 @@ RCoreSymCacheElement *r_coresym_cache_element_new(RBinFile *bf, RBuffer *buf, ut
sect->vaddr += page_zero_size;
}
cursor += word_size;
if (cursor >= end) {
if (cursor + word_size >= end) {
break;
}
sect->size = r_read_ble (cursor, false, bits);
cursor += word_size;
if (cursor >= end) {
if (cursor + word_size >= end) {
break;
}
ut64 sect_name_off = r_read_ble (cursor, false, bits);
Expand All @@ -291,7 +291,11 @@ RCoreSymCacheElement *r_coresym_cache_element_new(RBinFile *bf, RBuffer *buf, ut
cursor += word_size;
}
string_origin = relative_to_strings? b + start_of_strings : sect_start;
sect->name = str_dup_safe (b, string_origin + (size_t)sect_name_off, end);
if (sect_name_off < (ut64)(size_t)(end - string_origin)) {
sect->name = str_dup_safe (b, string_origin + sect_name_off, end);
} else {
sect->name = strdup ("");
}
}
}
if (hdr->n_symbols) {
Expand Down

0 comments on commit 1dd6533

Please sign in to comment.