Re: [PATCH v6 53/59] perf: Remove libperl support, legacy Perl scripts and tests

sashiko-bot
2026-04-25T18:19:22Z

Sashiko AI review found 1 potential issue(s):
- [Medium] Event matching logic is broken by an incorrect snprintf length argument in check_ev_match().
--

commit 358c8fb5b2850826fc33a7ec1709b3b089c45e16
Author: Ian Rogers <irogers@google.com>

perf: Remove libperl support, legacy Perl scripts and tests

This commit removes libperl support from perf, along with the legacy Perl
scripts and their corresponding tests.

> diff --git a/tools/perf/ui/browsers/scripts.c b/tools/perf/ui/browsers/scripts.c
> index 1e8c2c2f952d..db5559311a1f 100644
> --- a/tools/perf/ui/browsers/scripts.c
> +++ b/tools/perf/ui/browsers/scripts.c
[ ... ]
> @@ -126,8 +126,10 @@ static int check_ev_match(int dir_fd, const char *scriptname, struct perf_sessio
> len = strcspn(p, " \t");
> if (!len)
> break;
> + if ((size_t)len >= sizeof(evname))
> + len = sizeof(evname) - 1;
>
> - snprintf(evname, len + 1, "%s", p);
> + snprintf(evname, sizeof(evname), "%s", p);

Does this snprintf call ignore the calculated len and copy the rest of the
line instead?

Since p contains the remainder of the line, using sizeof(evname) instead of
len + 1 will capture trailing spaces and subsequent arguments into evname.
This will cause the evsel__name_is() match to fail.

Should this still use len + 1, or perhaps use %.*s with len to properly cap
the parsed token?

--
Sashiko AI review · https://sashiko.dev/#/patchset/20260425174858.3922152-1-irogers@google.com?part=53