mirror of
https://github.com/radareorg/radare2.git
synced 2024-11-23 13:19:54 +00:00
Fix #6585 - aac uses invalid range with -m
This commit is contained in:
parent
4ecf00e34e
commit
c2ea513969
@ -3525,50 +3525,51 @@ static void cmd_anal_calls(RCore *core, const char *input) {
|
||||
return;
|
||||
}
|
||||
binfile = r_core_bin_cur (core);
|
||||
if (!binfile) {
|
||||
eprintf ("cur binfile null\n");
|
||||
return;
|
||||
}
|
||||
addr = core->offset;
|
||||
if (!len) {
|
||||
// ignore search.in to avoid problems. analysis != search
|
||||
RIOSection *s = r_io_section_vget (core->io, addr);
|
||||
if (s && s->rwx & 1) {
|
||||
// search in current section
|
||||
if (s->size > binfile->size) {
|
||||
addr = s->vaddr;
|
||||
if (binfile->size > s->offset) {
|
||||
len = binfile->size - s->offset;
|
||||
} else {
|
||||
eprintf ("Opps something went wrong aac\n");
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
addr = s->vaddr;
|
||||
len = s->size;
|
||||
}
|
||||
} else {
|
||||
// search in full file
|
||||
ut64 o = r_io_section_vaddr_to_maddr (core->io, core->offset);
|
||||
if (o != UT64_MAX && binfile->size > o) {
|
||||
len = binfile->size - o;
|
||||
} else {
|
||||
if (binfile->size > core->offset) {
|
||||
if (binfile->size > core->offset) {
|
||||
len = binfile->size - core->offset;
|
||||
if (binfile) {
|
||||
if (!len) {
|
||||
// ignore search.in to avoid problems. analysis != search
|
||||
RIOSection *s = r_io_section_vget (core->io, addr);
|
||||
if (s && s->rwx & 1) {
|
||||
// search in current section
|
||||
if (s->size > binfile->size) {
|
||||
addr = s->vaddr;
|
||||
if (binfile->size > s->offset) {
|
||||
len = binfile->size - s->offset;
|
||||
} else {
|
||||
eprintf ("Opps something went wrong aac\n");
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
eprintf ("Oops invalid range\n");
|
||||
len = 0;
|
||||
addr = s->vaddr;
|
||||
len = s->size;
|
||||
}
|
||||
} else {
|
||||
// search in full file
|
||||
ut64 o = r_io_section_vaddr_to_maddr (core->io, core->offset);
|
||||
if (o != UT64_MAX && binfile->size > o) {
|
||||
len = binfile->size - o;
|
||||
} else {
|
||||
if (binfile->size > core->offset) {
|
||||
if (binfile->size > core->offset) {
|
||||
len = binfile->size - core->offset;
|
||||
} else {
|
||||
eprintf ("Opps something went wrong aac\n");
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
eprintf ("Oops invalid range\n");
|
||||
len = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
addr_end = addr + len;
|
||||
} else {
|
||||
const char *search_in = r_config_get (core->config, "search.in");
|
||||
r_list_free (r_core_get_boundaries_prot (core, 0, search_in, &addr, &addr_end));
|
||||
}
|
||||
addr_end = addr + len;
|
||||
if (!(buf = malloc (4096))) {
|
||||
if (!(buf = calloc (1, 4096))) {
|
||||
return;
|
||||
}
|
||||
bufi = 0;
|
||||
|
11
libr/io/io.c
11
libr/io/io.c
@ -337,9 +337,11 @@ R_API int r_io_read(RIO *io, ut8 *buf, int len) {
|
||||
if (!io || !io->desc || !buf || io->off == UT64_MAX)
|
||||
return -1;
|
||||
/* IGNORE check section permissions */
|
||||
if (io->enforce_rwx & R_IO_READ)
|
||||
if (!(r_io_section_get_rwx (io, io->off) & R_IO_READ))
|
||||
if (io->enforce_rwx & R_IO_READ) {
|
||||
if (!(r_io_section_get_rwx (io, io->off) & R_IO_READ)) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
/* io->off is in maddr, but r_io_read_at works in vaddr
|
||||
* FIXME: in some cases, r_io_seek sets io->off in vaddr */
|
||||
ut64 vaddr = r_io_section_maddr_to_vaddr(io, io->off);
|
||||
@ -1142,6 +1144,11 @@ if (hasperm) {
|
||||
r_io_section_exists_for_vaddr (io, offset, hasperm));
|
||||
}
|
||||
#endif
|
||||
if (r_list_empty (io->sections)) {
|
||||
if ((r_io_map_exists_for_offset (io, offset))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (!io_va) {
|
||||
if ((r_io_map_exists_for_offset (io, offset))) {
|
||||
return true;
|
||||
|
Loading…
Reference in New Issue
Block a user