malloc:// forces rw and fix regression in 'f'

This commit is contained in:
pancake 2016-07-03 22:36:42 +02:00
parent 622e828e1d
commit 4c97858e31
3 changed files with 11 additions and 8 deletions

View File

@ -158,7 +158,7 @@ R_API void r_flag_list(RFlag *f, int rad, const char *pfx) {
if (IS_IN_SPACE (f, flag)) {
continue;
}
if (!in_range || flag->offset < range_from || flag->offset >= range_to) {
if (in_range && (flag->offset < range_from || flag->offset >= range_to)) {
continue;
}
r_cons_printf ("%s{\"name\":\"%s\",\"size\":\"%"PFMT64d"\",",
@ -182,7 +182,7 @@ R_API void r_flag_list(RFlag *f, int rad, const char *pfx) {
if (IS_IN_SPACE (f, flag)) {
continue;
}
if (!in_range || flag->offset < range_from || flag->offset >= range_to) {
if (in_range && (flag->offset < range_from || flag->offset >= range_to)) {
continue;
}
if (fs == -1 || flag->space != fs) {
@ -211,7 +211,7 @@ R_API void r_flag_list(RFlag *f, int rad, const char *pfx) {
if (IS_IN_SPACE (f, flag)) {
continue;
}
if (!in_range || flag->offset < range_from || flag->offset >= range_to) {
if (in_range && (flag->offset < range_from || flag->offset >= range_to)) {
continue;
}
if (flag->alias) {
@ -228,7 +228,7 @@ R_API void r_flag_list(RFlag *f, int rad, const char *pfx) {
if (IS_IN_SPACE (f, flag)) {
continue;
}
if (!in_range || flag->offset < range_from || flag->offset >= range_to) {
if (in_range && (flag->offset < range_from || flag->offset >= range_to)) {
continue;
}
if (flag->alias) {

View File

@ -214,7 +214,9 @@ R_API RIODesc *r_io_open_at(RIO *io, const char *file, int flags, int mode, ut64
r_io_use_desc (io, desc);
}
r_io_map_new (io, desc->fd, mode, 0, maddr, size);
} else eprintf ("r_io_open_at: Unable to open file: %s\n", file);
} else {
eprintf ("r_io_open_at: Unable to open file: %s\n", file);
}
return desc;
}

View File

@ -113,6 +113,7 @@ static RIODesc *__open(RIO *io, const char *pathname, int rw, int mode) {
if (__check (io, pathname, 0)) {
RIOMalloc *mal = R_NEW0 (RIOMalloc);
if (!mal) return NULL;
rw = 7; // RWX
mal->fd = -2; /* causes r_io_desc_new() to set the correct fd */
if (!strncmp (pathname, "hex://", 6)) {
mal->size = strlen (pathname);
@ -131,7 +132,7 @@ static RIODesc *__open(RIO *io, const char *pathname, int rw, int mode) {
mal->size = r_num_math (NULL, pathname + 9);
if (((int)mal->size) <= 0) {
free (mal);
eprintf ("Cannot allocate (%s) 0 bytes\n", pathname+9);
eprintf ("Cannot allocate (%s) 0 bytes\n", pathname + 9);
return NULL;
}
mal->offset = 0;
@ -139,9 +140,9 @@ static RIODesc *__open(RIO *io, const char *pathname, int rw, int mode) {
}
if (mal->buf) {
RETURN_IO_DESC_NEW (&r_io_plugin_malloc,
mal->fd, pathname, rw, mode,mal);
mal->fd, pathname, rw, mode, mal);
}
eprintf ("Cannot allocate (%s) %d bytes\n", pathname+9, mal->size);
eprintf ("Cannot allocate (%s) %d bytes\n", pathname + 9, mal->size);
free (mal);
}
return NULL;