Skip to content

Commit

Permalink
Fix another oobread segfault in the NE bin parser ##crash
Browse files Browse the repository at this point in the history
* Reported by @Han0nly via huntr.dev
* Reproducers: sample1 sample2 sample3
* BountyID: 47422cdf-aad2-4405-a6a1-6f63a3a93200
  • Loading branch information
radare authored and trufae committed Apr 5, 2022
1 parent 2d782cd commit c40a4f9
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion libr/bin/format/ne/ne.c
Expand Up @@ -374,6 +374,9 @@ RList *r_bin_ne_get_entrypoints(r_bin_ne_obj_t *bin) {
}
int off = 0;
while (off < bin->ne_header->EntryTableLength) {
if (bin->entry_table + off + 32 >= r_buf_size (bin->buf)) {
break;
}
ut8 bundle_length = *(ut8 *)(bin->entry_table + off);
if (!bundle_length) {
break;
Expand All @@ -398,7 +401,9 @@ RList *r_bin_ne_get_entrypoints(r_bin_ne_obj_t *bin) {
ut8 segnum = *(bin->entry_table + off);
off++;
ut16 segoff = *(ut16 *)(bin->entry_table + off);
entry->paddr = (ut64)bin->segment_entries[segnum - 1].offset * bin->alignment + segoff;
if (segnum > 0) {
entry->paddr = (ut64)bin->segment_entries[segnum - 1].offset * bin->alignment + segoff;
}
} else { // Fixed
entry->paddr = (ut64)bin->segment_entries[bundle_type - 1].offset * bin->alignment + *(ut16 *)(bin->entry_table + off);
}
Expand Down

0 comments on commit c40a4f9

Please sign in to comment.