selftests/bpf: correctly move 'log' upon successful match
BugLink: https://bugs.launchpad.net/bugs/2089340 commit d0a29cdb6ef95d8a175e09ab2d1334271f047e60 upstream. Suppose log="foo bar buz" and msg->substr="bar". In such case current match processing logic would update 'log' as follows: log += strlen(msg->substr); -> log += 3 -> log=" bar". However, the intent behind the 'log' update is to make it point after the successful match, e.g. to make log=" buz" in the example above. Fixes: 4ef5d6af4935 ("selftests/bpf: no need to track next_match_pos in struct test_loader") Signed-off-by: Eduard Zingerman <eddyz87@gmail.com> Link: https://lore.kernel.org/r/20240820102357.3372779-3-eddyz87@gmail.com Signed-off-by: Alexei Starovoitov <ast@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Portia Stephens <portia.stephens@canonical.com> Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
This commit is contained in:
committed by
Mehmet Basaran
parent
5f05d8b5ed
commit
e1dac5954a
@@ -522,7 +522,7 @@ static void validate_msgs(char *log_buf, struct expected_msgs *msgs,
|
||||
if (msg->substr) {
|
||||
match = strstr(log, msg->substr);
|
||||
if (match)
|
||||
log += strlen(msg->substr);
|
||||
log = match + strlen(msg->substr);
|
||||
} else {
|
||||
err = regexec(&msg->regex, log, 1, reg_match, 0);
|
||||
if (err == 0) {
|
||||
|
||||
Reference in New Issue
Block a user