mirror of
https://github.com/radareorg/radare2.git
synced 2024-12-14 08:49:50 +00:00
A fix for a MACH0 crash
This commit is contained in:
parent
d47b488a0f
commit
262b0cfd55
@ -1225,7 +1225,7 @@ R_API RBin* r_bin_new() {
|
||||
bin->binxtrs = r_list_new ();
|
||||
bin->binxtrs->free = free;
|
||||
for (i=0; bin_xtr_static_plugins[i]; i++) {
|
||||
static_xtr_plugin = R_NEW (RBinXtrPlugin);
|
||||
static_xtr_plugin = R_NEW0 (RBinXtrPlugin);
|
||||
*static_xtr_plugin = *bin_xtr_static_plugins[i];
|
||||
r_bin_xtr_add (bin, static_xtr_plugin);
|
||||
}
|
||||
|
@ -936,9 +936,13 @@ struct reloc_t* MACH0_(get_relocs)(struct MACH0_(obj_t)* bin) {
|
||||
break;
|
||||
case BIND_OPCODE_SET_SEGMENT_AND_OFFSET_ULEB:
|
||||
seg_idx = imm;
|
||||
if (seg_idx<0 || seg_idx > bin->nsegs )
|
||||
eprintf ("Error: BIND_OPCODE_SET_SEGMENT_AND_OFFSET_ULEB has unexistent segment %d\n", seg_idx);
|
||||
addr = bin->segs[seg_idx].vmaddr + ULEB();
|
||||
if (seg_idx<0 || seg_idx >= bin->nsegs) {
|
||||
eprintf ("Error: BIND_OPCODE_SET_SEGMENT_AND_OFFSET_ULEB"
|
||||
" has unexistent segment %d\n", seg_idx);
|
||||
addr = 0LL;
|
||||
} else {
|
||||
addr = bin->segs[seg_idx].vmaddr + ULEB();
|
||||
}
|
||||
break;
|
||||
case BIND_OPCODE_ADD_ADDR_ULEB:
|
||||
addr += ULEB();
|
||||
|
@ -99,6 +99,7 @@ static RList* sections(RBinFile *arch) {
|
||||
if (!(ptr = R_NEW0 (RBinSection)))
|
||||
break;
|
||||
strncpy (ptr->name, (char*)sections[i].name, R_BIN_SIZEOF_STRINGS);
|
||||
ptr->name[R_BIN_SIZEOF_STRINGS] = 0;
|
||||
ptr->size = sections[i].size;
|
||||
ptr->vsize = sections[i].size;
|
||||
ptr->paddr = sections[i].offset + obj->boffset;
|
||||
@ -211,7 +212,7 @@ static RList* relocs(RBinFile *arch) {
|
||||
// TODO(eddyb) filter these out earlier.
|
||||
if (!relocs[i].addr)
|
||||
continue;
|
||||
if (!(ptr = R_NEW (RBinReloc)))
|
||||
if (!(ptr = R_NEW0 (RBinReloc)))
|
||||
break;
|
||||
ptr->type = relocs[i].type;
|
||||
ptr->additive = 0;
|
||||
|
@ -1081,8 +1081,6 @@ static int bin_sections (RCore *r, int mode, ut64 baddr, ut64 laddr, int va, ut6
|
||||
r_flag_set (r->flags, str, addr, section->size, 0);
|
||||
snprintf (str, sizeof(str)-1, "section_end.%s", section->name);
|
||||
r_flag_set (r->flags, str, addr + section->size, 0, 0);
|
||||
r_io_section_add (r->io, section->paddr, addr, section->size,
|
||||
section->vsize, section->srwx, section->name, 0, fd);
|
||||
if (section->arch || section->bits) {
|
||||
const char *arch = section->arch;
|
||||
int bits = section->bits;
|
||||
@ -1090,15 +1088,17 @@ static int bin_sections (RCore *r, int mode, ut64 baddr, ut64 laddr, int va, ut6
|
||||
if (!bits) bits = info->bits;
|
||||
//r_io_section_set_archbits (r->io, addr, arch, bits);
|
||||
}
|
||||
snprintf (str, sizeof(str)-1, "[%i] va=0x%08"PFMT64x" pa=0x%08"PFMT64x" sz=%"
|
||||
snprintf (str, sizeof (str)-1, "[%i] va=0x%08"PFMT64x" pa=0x%08"PFMT64x" sz=%"
|
||||
PFMT64d" vsz=%"PFMT64d" rwx=%c%c%c%c %s",
|
||||
i++, addr, section->paddr, section->size, section->vsize,
|
||||
(R_BIN_SCN_SHAREABLE §ion->srwx)?'s':'-',
|
||||
(R_BIN_SCN_READABLE §ion->srwx)?'r':'-',
|
||||
(R_BIN_SCN_WRITABLE §ion->srwx)?'w':'-',
|
||||
(R_BIN_SCN_EXECUTABLE §ion->srwx)?'x':'-',
|
||||
(R_BIN_SCN_SHAREABLE & section->srwx)?'s':'-',
|
||||
(R_BIN_SCN_READABLE & section->srwx)?'r':'-',
|
||||
(R_BIN_SCN_WRITABLE & section->srwx)?'w':'-',
|
||||
(R_BIN_SCN_EXECUTABLE & section->srwx)?'x':'-',
|
||||
section->name);
|
||||
r_meta_add (r->anal, R_META_TYPE_COMMENT, addr, addr, str);
|
||||
r_io_section_add (r->io, section->paddr, addr, section->size,
|
||||
section->vsize, section->srwx, section->name, 0, fd);
|
||||
}
|
||||
// H -> Header fields
|
||||
if (0) {
|
||||
|
Loading…
Reference in New Issue
Block a user