Skip to content

Commit d0a29cd

Browse files
eddyz87Alexei Starovoitov
authored andcommitted
selftests/bpf: correctly move 'log' upon successful match
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: 4ef5d6a ("selftests/bpf: no need to track next_match_pos in struct test_loader") Signed-off-by: Eduard Zingerman <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Alexei Starovoitov <[email protected]>
1 parent 7d41dad commit d0a29cd

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

tools/testing/selftests/bpf/test_loader.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,7 @@ static void validate_msgs(char *log_buf, struct expected_msgs *msgs,
522522
if (msg->substr) {
523523
match = strstr(log, msg->substr);
524524
if (match)
525-
log += strlen(msg->substr);
525+
log = match + strlen(msg->substr);
526526
} else {
527527
err = regexec(&msg->regex, log, 1, reg_match, 0);
528528
if (err == 0) {

0 commit comments

Comments
 (0)