mirror of
https://github.com/radareorg/radare2.git
synced 2025-01-31 10:22:37 +00:00
Fix #1670 - r2 -d 'ls -l /' working again
This commit is contained in:
parent
6a61fdfbd3
commit
b1da2b30e3
@ -508,22 +508,34 @@ R_API int r_bin_load_io_at_offset_as_sz(RBin *bin, RIODesc *desc, ut64 baseaddr,
|
|||||||
buf_bytes = NULL;
|
buf_bytes = NULL;
|
||||||
file_sz = iob->desc_size (io, desc);
|
file_sz = iob->desc_size (io, desc);
|
||||||
if ((file_sz == 0 || file_sz == UT64_MAX) && is_debugger) {
|
if ((file_sz == 0 || file_sz == UT64_MAX) && is_debugger) {
|
||||||
|
int fail = 1;
|
||||||
|
/* get file path from desc name */
|
||||||
|
/* - asume path+exec have no space in path */
|
||||||
|
char *filepath, *foo = strdup (desc->name);
|
||||||
|
filepath = strchr (foo, ' ');
|
||||||
|
if (filepath) *filepath = 0;
|
||||||
|
filepath = r_file_path (foo);
|
||||||
|
|
||||||
// attempt a local open and read
|
// attempt a local open and read
|
||||||
// This happens when a plugin like debugger does not have a fixed size.
|
// This happens when a plugin like debugger does not have a fixed size.
|
||||||
// if there is no fixed size or its MAXED, there is no way to definitively
|
// if there is no fixed size or its MAXED, there is no way to definitively
|
||||||
// load the bin-properly. Many of the plugins require all content and are not
|
// load the bin-properly. Many of the plugins require all content and are not
|
||||||
// stream based loaders
|
// stream based loaders
|
||||||
// NOTE: For RBin we dont need to open the file in read-write. This can be problematic
|
// NOTE: For RBin we dont need to open the file in read-write. This can be problematic
|
||||||
RIODesc *tdesc = iob->desc_open (io, desc->name, R_IO_READ, 0); //desc->flags, R_IO_READ);
|
RIODesc *tdesc = iob->desc_open (io, filepath, R_IO_READ, 0); //desc->flags, R_IO_READ);
|
||||||
if (!tdesc) return R_FALSE;
|
if (tdesc) {
|
||||||
file_sz = iob->desc_size (io, tdesc);
|
file_sz = iob->desc_size (io, tdesc);
|
||||||
if (file_sz == UT64_MAX) {
|
if (file_sz != UT64_MAX) {
|
||||||
|
sz = R_MIN (file_sz, sz);
|
||||||
|
buf_bytes = iob->desc_read (io, tdesc, &sz);
|
||||||
|
fail = 0;
|
||||||
|
}
|
||||||
iob->desc_close (io, tdesc);
|
iob->desc_close (io, tdesc);
|
||||||
return R_FALSE;
|
|
||||||
}
|
}
|
||||||
sz = R_MIN (file_sz, sz);
|
free (foo);
|
||||||
buf_bytes = iob->desc_read (io, tdesc, &sz);
|
free (filepath);
|
||||||
iob->desc_close (io, tdesc);
|
if (fail)
|
||||||
|
return R_FALSE;
|
||||||
} else if (sz != UT64_MAX) {
|
} else if (sz != UT64_MAX) {
|
||||||
sz = R_MIN (file_sz, sz);
|
sz = R_MIN (file_sz, sz);
|
||||||
buf_bytes = iob->desc_read (io, desc, &sz);
|
buf_bytes = iob->desc_read (io, desc, &sz);
|
||||||
|
@ -558,8 +558,14 @@ R_API int r_run_start(RRunProfile *p) {
|
|||||||
}
|
}
|
||||||
if (p->_program) {
|
if (p->_program) {
|
||||||
if (!r_file_exists (p->_program)) {
|
if (!r_file_exists (p->_program)) {
|
||||||
eprintf ("rarun2: %s: file not found\n", p->_program);
|
char *progpath = r_file_path (p->_program);
|
||||||
return 1;
|
if (progpath && *progpath) {
|
||||||
|
free (p->_program);
|
||||||
|
p->_program = progpath;
|
||||||
|
} else {
|
||||||
|
eprintf ("rarun2: %s: file not found\n", p->_program);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// XXX HACK close all non-tty fds
|
// XXX HACK close all non-tty fds
|
||||||
{ int i; for (i=3; i<10; i++) close (i); }
|
{ int i; for (i=3; i<10; i++) close (i); }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user