Skip to content

Commit

Permalink
$: Use rz_flag_get to check if flag exists (#4377)
Browse files Browse the repository at this point in the history
  • Loading branch information
kazarmy authored Mar 22, 2024
1 parent ab593b3 commit c52750c
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
6 changes: 3 additions & 3 deletions librz/core/cmd/cmd_alias.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,9 @@ RZ_IPI RzCmdStatus rz_alias_handler(RzCore *core, int argc, const char **argv) {
rz_core_cmd0(core, v);
}
} else {
ut64 at = rz_num_get(core->num, buf + 1);
if (at != UT64_MAX) {
rz_core_seek(core, at, true);
RzFlagItem *flag = rz_flag_get(core->flags, buf + 1);
if (flag) {
rz_core_seek(core, flag->offset, true);
} else {
RZ_LOG_ERROR("core: unknown alias '%s'\n", buf + 1);
free(buf);
Expand Down
3 changes: 2 additions & 1 deletion test/db/archos/darwin-x64/cmd_i
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ FILE==
CMDS=<<EOF
cd `e dir.tmp`
e io.cache=true
(show_fname fname; wz ${fname}; prz `$b` > `prz`; o `prz`; i~file; ij; rm `prz`)
(show_fname fname; wz ${fname}; prz `$size` > `prz`; o `prz`; i~file; ij; rm `prz`)
$size=%l \`prz\`
.(show_fname A\x1b¢\302\200€𝄞\363\240\201\201\\.bin)
.(show_fname B\x1b¢\302\200€𝄞\363\240\201\201\\.bin)
# INVALID FILENAME .(show_fname B\x1b¢\302\200\201€𝄞\363\240\201\201\\.bin)
Expand Down
1 change: 1 addition & 0 deletions test/db/archos/linux-any/cmd_i
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ CMDS=<<EOF
cd `e dir.tmp`
e io.cache=true
(show_fname fname; wz ${fname}; prz `$size` > `prz` ; o `prz`; i~file; ij; rm `prz`)
$size=%l \`prz\`
.(show_fname A\x1b¢\302\200€𝄞\363\240\201\201\\.bin)
.(show_fname B\x1b¢\302\200€𝄞\363\240\201\201\\.bin)
.(show_fname B\x1b¢\302\200\201€𝄞\363\240\201\201\\.bin)
Expand Down
8 changes: 8 additions & 0 deletions test/db/cmd/cmd_alias
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,11 @@ $dis=base64:cGRm
$dis=pdf
EOF
RUN

NAME=Alias not found
FILE=--
CMDS=$dis
EXPECT_ERR=<<EOF
ERROR: core: unknown alias 'dis'
EOF
RUN

0 comments on commit c52750c

Please sign in to comment.