Skip to content

Commit

Permalink
Fix radareorg#16347: o+ sets maps as writable like oo+
Browse files Browse the repository at this point in the history
  • Loading branch information
kazarmy committed Apr 1, 2020
1 parent 9ae037e commit e8c393a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
10 changes: 10 additions & 0 deletions libr/core/cmd_open.c
Original file line number Diff line number Diff line change
Expand Up @@ -1390,6 +1390,7 @@ static int cmd_open(void *data, const char *input) {
break;
case '+': // "o+"
perms |= R_PERM_W;
/* fallthrough */
case ' ': // "o" "o "
ptr = input + 1;
argv = r_str_argv (ptr, &argc);
Expand Down Expand Up @@ -1422,6 +1423,15 @@ static int cmd_open(void *data, const char *input) {
addr = UT64_MAX;
}
r_core_bin_load (core, argv0, addr);
if (*input == '+') { // "o+"
SdbListIter *iter;
RIOMap *map;
ls_foreach_prev (core->io->maps, iter, map) {
if (map->fd == fd) {
map->perm |= R_PERM_WX;
}
}
}
} else {
eprintf ("cannot open file %s\n", argv0);
}
Expand Down
8 changes: 4 additions & 4 deletions test/new/db/cmd/cmd_open
Original file line number Diff line number Diff line change
Expand Up @@ -338,10 +338,10 @@ om
# pv1
EOF
EXPECT=<<EOF
5 fd: 3 +0x00000000 0x00000000 - 0x0000347f r-- fmap.LOAD0
4 fd: 3 +0x00004000 0x00004000 - 0x00016790 r-x fmap.LOAD1
3 fd: 3 +0x00017000 0x00017000 - 0x0001f7bf r-- fmap.LOAD2
2 fd: 3 +0x00020050 0x00021050 - 0x00022267 rw- fmap.LOAD3
5 fd: 3 +0x00000000 0x00000000 - 0x0000347f rwx fmap.LOAD0
4 fd: 3 +0x00004000 0x00004000 - 0x00016790 rwx fmap.LOAD1
3 fd: 3 +0x00017000 0x00017000 - 0x0001f7bf rwx fmap.LOAD2
2 fd: 3 +0x00020050 0x00021050 - 0x00022267 rwx fmap.LOAD3
1 fd: 4 +0x00000000 0x00022268 - 0x00023557 rw- mmap.LOAD3
EOF
RUN
Expand Down

0 comments on commit e8c393a

Please sign in to comment.