Fix onnu command usage and test

This commit is contained in:
pancake 2022-07-07 03:38:32 +02:00 committed by pancake
parent a7399890fe
commit f2edc67c97
2 changed files with 15 additions and 7 deletions

View File

@ -21,7 +21,7 @@ static const char *help_msg_o[] = {
"ob","[?] [lbdos] [...]","list opened binary files backed by fd",
"oc"," [file]","open core file, like relaunching r2",
"of","[?] [file]","open file and map it at addr 0 as read-only",
"oj","[?] ","list opened files in JSON format",
"oj","[?]","list opened files in JSON format",
"om","[?]","create, list, remove IO maps",
"on","[?][n] [file] 0x4000","map raw file at 0x4000 (no r_bin involved)",
"oo","[?][+bcdnm]","reopen current file (see oo?) (reload in rw or debugger)",
@ -1619,11 +1619,17 @@ static bool cmd_onn(RCore *core, const char* input) {
while (*arg0 && *arg0 != ' ') {
arg0++;
}
arg0 = r_str_trim_head_ro (arg0);
if (!*arg0) {
eprintf ("Usage: onn[u] [file] [perm]\n");
return false;
}
char *ptr = r_str_trim_dup (arg0);
int perms = R_PERM_R;
char *arg_perm = strchr (ptr, ' ');
if (arg_perm) {
*arg_perm++ = 0;
arg0 = ptr;
perms = r_str_rwx (arg_perm);
}
Onn on = {arg0, NULL, core};

View File

@ -31,6 +31,7 @@ RUN
NAME=Reloading a project twice fails
FILE=bins/mach0/ls-m1
ARGS=-a x86 -b 64
CMDS=<<EOF
e prj.vc=false
e scr.interactive=false
@ -391,10 +392,11 @@ P+ ulumulu > /dev/null
PS*~^o
Px
o--
Po ulumulu > /dev/null
?e ooo
o
?e ooo
Po ulumulu > /dev/null
?e files:
o
?e count:
o*~?
EOF
EXPECT=<<EOF
@ -407,10 +409,10 @@ onnu null://8 rw-
omu 4 0x00600910 0x00000008 0x00000000 rw- mmap.LOAD1
omu 3 0x006006e0 0x00000230 0x000006e0 r-- fmap.LOAD1
omu 3 0x00400000 0x000006dc 0x00000000 r-x fmap.LOAD0
ooo
files:
3 - r-x 0x000021da bins/elf/analysis/main
4 - rw- 0x00000008 null://8
ooo
4 * rw- 0x00000008 null://8
count:
4
EOF
RUN