mirror of
https://github.com/radareorg/radare2.git
synced 2024-12-14 08:49:50 +00:00
Fix #3807 - write on maps issue
This commit is contained in:
parent
eb51d68d3a
commit
61fba1e663
@ -121,7 +121,7 @@ typedef struct r_io_t {
|
||||
int raised;
|
||||
int va;
|
||||
int raw;
|
||||
int vio; //remove that when vio replaces the old stuff
|
||||
int vio; // remove that when vio replaces the old stuff
|
||||
int sectonly;
|
||||
char *referer;
|
||||
char *redirect;
|
||||
|
12
libr/io/io.c
12
libr/io/io.c
@ -626,7 +626,11 @@ R_API int r_io_write(RIO *io, const ut8 *buf, int len) {
|
||||
|
||||
/* apply write binary mask */
|
||||
if (io->write_mask_fd != -1) {
|
||||
data = malloc (len);
|
||||
data = (len>0)? malloc (len): NULL;
|
||||
if (!data) {
|
||||
eprintf ("malloc failed in write_mask_fd");
|
||||
return -1;
|
||||
}
|
||||
r_io_seek (io, io->off, R_IO_SEEK_SET);
|
||||
r_io_read (io, data, len);
|
||||
r_io_seek (io, io->off, R_IO_SEEK_SET);
|
||||
@ -642,6 +646,12 @@ R_API int r_io_write(RIO *io, const ut8 *buf, int len) {
|
||||
r_io_map_select (io, io->off);
|
||||
io->off = addr;
|
||||
}
|
||||
{
|
||||
RIOMap *map = r_io_map_get (io, io->off);
|
||||
if (map) {
|
||||
io->off -= map->from;
|
||||
}
|
||||
}
|
||||
|
||||
if (io->plugin) {
|
||||
if (io->plugin->write) {
|
||||
|
@ -76,8 +76,11 @@ R_API RIOMap *r_io_map_get(RIO *io, ut64 addr) {
|
||||
RIOMap *map;
|
||||
RListIter *iter;
|
||||
r_list_foreach (io->maps, iter, map) {
|
||||
if ((map->from <= addr) && (addr < map->to))
|
||||
if (map->from == map->to && map >= map->from) {
|
||||
return map;
|
||||
} else if (map >= map->from && map < map->to) {
|
||||
return map;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user