Fix #6676 - rbin warn after re-o

This commit is contained in:
pancake 2017-02-03 20:47:09 +01:00
parent f5e1294969
commit 8ecf4238fd
4 changed files with 10 additions and 21 deletions

View File

@ -833,14 +833,11 @@ R_API int r_bin_reload(RBin *bin, RIODesc *desc, ut64 baseaddr) {
R_API int r_bin_load_io(RBin *bin, RIODesc *desc, ut64 baseaddr, ut64 loadaddr,
int xtr_idx) {
return r_bin_load_io_at_offset_as (bin, desc, baseaddr, loadaddr,
xtr_idx, 0, NULL);
return r_bin_load_io_at_offset_as (bin, desc, baseaddr, loadaddr, xtr_idx, 0, NULL);
}
R_API int r_bin_load_io_at_offset_as_sz (RBin *bin, RIODesc *desc,
ut64 baseaddr, ut64 loadaddr,
int xtr_idx, ut64 offset,
const char *name, ut64 sz) {
R_API int r_bin_load_io_at_offset_as_sz (RBin *bin, RIODesc *desc, ut64 baseaddr,
ut64 loadaddr, int xtr_idx, ut64 offset, const char *name, ut64 sz) {
RIOBind *iob = &(bin->iob);
RIO *io = iob? iob->get_io (iob): NULL;
RListIter *it;
@ -900,13 +897,10 @@ R_API int r_bin_load_io_at_offset_as_sz (RBin *bin, RIODesc *desc,
return false;
}
}
} else if (sz == UT64_MAX) {
return false;
}
sz = R_MIN (file_sz, sz);
if (!buf_bytes) {
ut64 seekaddr = is_debugger? baseaddr: loadaddr;
iob->desc_seek (io, desc, seekaddr);
buf_bytes = iob->desc_read (io, desc, &sz);
if (!buf_bytes) {
@ -959,11 +953,8 @@ R_API int r_bin_load_io_at_offset_as_sz (RBin *bin, RIODesc *desc,
xtr->extractall_from_bytes)) {
if (is_debugger && sz != file_sz) {
free (buf_bytes);
RIODesc *tdesc =
iob->desc_open (
io, desc->name,
desc->flags,
R_IO_READ);
RIODesc *tdesc = iob->desc_open (io,
desc->name, desc->flags, R_IO_READ);
if (!tdesc) {
return false;
}
@ -993,15 +984,13 @@ R_API int r_bin_load_io_at_offset_as_sz (RBin *bin, RIODesc *desc,
bin, desc->name, buf_bytes, sz, file_sz, bin->rawstr,
baseaddr, loadaddr, desc->fd, name, NULL, offset);
}
free (buf_bytes);
return binfile? r_bin_file_set_cur_binfile (bin, binfile): false;
}
R_API int r_bin_load_io_at_offset_as(RBin *bin, RIODesc *desc, ut64 baseaddr,
ut64 loadaddr, int xtr_idx, ut64 offset,
const char *name) {
R_API bool r_bin_load_io_at_offset_as(RBin *bin, RIODesc *desc, ut64 baseaddr,
ut64 loadaddr, int xtr_idx, ut64 offset, const char *name) {
// adding file_sz to help reduce the performance impact on the system
// in this case the number of bytes read will be limited to 2MB
// (MIN_LOAD_SIZE)

View File

@ -2321,7 +2321,7 @@ R_API RBuffer *r_core_syscallf (RCore *core, const char *name, const char *fmt,
R_API RBuffer *r_core_syscall (RCore *core, const char *name, const char *args) {
RBuffer *b = NULL;
char code[1024];
int i, num;
int num;
num = r_syscall_get_num (core->anal->syscall, name);
if (!num) {

View File

@ -360,7 +360,7 @@ static int r_core_file_do_load_for_debug (RCore *r, ut64 baseaddr, const char *f
int fd = desc->fd;
#endif
if (!r_bin_load (r->bin, filenameuri, baseaddr, UT64_MAX, xtr_idx, fd, treat_as_rawstr)) {
eprintf ("Cannot open %s\n", filenameuri);
eprintf ("RBinLoad: Cannot open %s\n", filenameuri);
if (r_config_get_i (r->config, "bin.rawstr")) {
treat_as_rawstr = true;
if (!r_bin_load (r->bin, filenameuri, baseaddr, UT64_MAX, xtr_idx, desc->fd, treat_as_rawstr)) {

View File

@ -481,7 +481,7 @@ R_API int r_bin_load(RBin *bin, const char *file, ut64 baseaddr, ut64 loadaddr,
R_API int r_bin_reload(RBin *bin, RIODesc *desc, ut64 baseaddr);
R_API int r_bin_load_as(RBin *bin, const char *file, ut64 baseaddr, ut64 loadaddr, int xtr_idx, int fd, int rawstr, int fileoffset, const char *name);
R_API int r_bin_load_io(RBin *bin, RIODesc *desc, ut64 baseaddr, ut64 loadaddr, int xtr_idx);
R_API int r_bin_load_io_at_offset_as(RBin *bin, RIODesc *desc, ut64 baseaddr, ut64 loadaddr, int xtr_idx, ut64 offset, const char *name);
R_API bool r_bin_load_io_at_offset_as(RBin *bin, RIODesc *desc, ut64 baseaddr, ut64 loadaddr, int xtr_idx, ut64 offset, const char *name);
R_API int r_bin_load_io_at_offset_as_sz(RBin *bin, RIODesc *desc, ut64 baseaddr, ut64 loadaddr, int xtr_idx, ut64 offset, const char *name, ut64 sz);
R_API void r_bin_bind(RBin *b, RBinBind *bnd);
R_API int r_bin_add(RBin *bin, RBinPlugin *foo);