Skip to content

Commit

Permalink
Fix inconsistency between / and /e (#4876)
Browse files Browse the repository at this point in the history
* Fix inconsistency between `/` and `/e`
* Change `char *` -> `const char *` in call to `rz_regex_match_all_not_grouped()`

Co-authored-by: Rot127 <[email protected]>
  • Loading branch information
kazarmy and Rot127 authored Feb 3, 2025
1 parent 2d039ee commit a5b348c
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 2 deletions.
4 changes: 2 additions & 2 deletions librz/search/regexp.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ RZ_API int rz_search_regexp_update(RzSearch *s, ut64 from, const ut8 *buf, int l
return -1;
}

matches = rz_regex_match_all_not_grouped(compiled, (char *)buf, len, from, RZ_REGEX_DEFAULT);
matches = rz_regex_match_all_not_grouped(compiled, (const char *)buf, len, 0, RZ_REGEX_DEFAULT);
void **it;
rz_pvector_foreach (matches, it) {
RzRegexMatch *m = *it;
kw->keyword_length = m->len; // For a regex search, the keyword can be of variable length
int t = rz_search_hit_new(s, kw, m->start);
int t = rz_search_hit_new(s, kw, from + m->start);
if (t == 0) {
ret = -1;
rz_pvector_free(matches);
Expand Down
47 changes: 47 additions & 0 deletions test/db/cmd/regexp
Original file line number Diff line number Diff line change
Expand Up @@ -113,3 +113,50 @@ Searching in [0x0,0x200)
hits: 1
EOF
RUN

NAME=consistency btw / and /e
FILE=bins/elf/analysis/ls2
CMDS=<<EOF
e scr.color=1
/ lib
echo ----
/e /lib/
EOF
EXPECT=<<EOF
0x00400239 hit0_0 ./lib64/ld-linux-x86-.
0x00400f19 hit0_1 .alibselinux.so.1_IT.
0x00400fae hit0_2 .etfilecon_finilibacl.so.1acl_get.
0x00400feb hit0_3 .l_extended_filelibc.so.6fflushst.
0x004013c3 hit0_4 .cmptcgetpgrp__libc_start_maindir.
0x0041769a hit0_5 .system call./.libs/lt-.
0x004186e0 hit0_6 .emory exhaustedlib/xstrtol.c0 <.
0x00418e58 hit0_7 .xstrtoumax/usr/libASCIICHARSETAL.
----
0x00400239 hit1_0 ./lib64/ld-linux-x86-.
0x00400f19 hit1_1 .alibselinux.so.1_IT.
0x00400fae hit1_2 .etfilecon_finilibacl.so.1acl_get.
0x00400feb hit1_3 .l_extended_filelibc.so.6fflushst.
0x004013c3 hit1_4 .cmptcgetpgrp__libc_start_maindir.
0x0041769a hit1_5 .system call./.libs/lt-.
0x004186e0 hit1_6 .emory exhaustedlib/xstrtol.c0 <.
0x00418e58 hit1_7 .xstrtoumax/usr/libASCIICHARSETAL.
EOF
EXPECT_ERR=<<EOF
Searching 3 bytes in [0x61d368,0x61d720)
hits: 0
Searching 3 bytes in [0x400000,0x41bc2c)
[ ] 0x00403a00 < 0x0041bc2c hits = 5 [# ][ ] 0x00407a00 < 0x0041bc2c hits = 5 [# ][ ] 0x0040ba00 < 0x0041bc2c hits = 5 [# ][ ] 0x0040fa00 < 0x0041bc2c hits = 5 [# ][ ] 0x00413a00 < 0x0041bc2c hits = 5 [# ][ ] 0x00417a00 < 0x0041bc2c hits = 6 [# ][ ] 0x0041ba00 < 0x0041bc2c hits = 8 [# ]hits: 8
Searching 3 bytes in [0x61c5f4,0x61d360)
hits: 0
Searching 3 bytes in [0x61bdf0,0x61c5f4)
hits: 0
Searching in [0x61d368,0x61d720)
hits: 0
Searching in [0x400000,0x41bc2c)
hits: 8
Searching in [0x61c5f4,0x61d360)
hits: 0
Searching in [0x61bdf0,0x61c5f4)
hits: 0
EOF
RUN
Expand Down

0 comments on commit a5b348c

Please sign in to comment.