Message ID | 20240907050830.6752-2-irogers@google.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | Tool and hwmon PMUs | expand |
On Fri, Sep 06, 2024 at 10:08:16PM -0700, Ian Rogers wrote: > If a desc string is 0 length then -1 will be out of bounds, add a > check. Cherry picked this one. - Arnaldo > Signed-off-by: Ian Rogers <irogers@google.com> > --- > tools/perf/builtin-list.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/tools/perf/builtin-list.c b/tools/perf/builtin-list.c > index 82cb4b1010aa..65b8cba324be 100644 > --- a/tools/perf/builtin-list.c > +++ b/tools/perf/builtin-list.c > @@ -173,7 +173,7 @@ static void default_print_event(void *ps, const char *pmu_name, const char *topi > if (pmu_name && strcmp(pmu_name, "default_core")) { > desc_len = strlen(desc); > desc_len = asprintf(&desc_with_unit, > - desc[desc_len - 1] != '.' > + desc_len > 0 && desc[desc_len - 1] != '.' > ? "%s. Unit: %s" : "%s Unit: %s", > desc, pmu_name); > } > -- > 2.46.0.469.g59c65b2a67-goog
diff --git a/tools/perf/builtin-list.c b/tools/perf/builtin-list.c index 82cb4b1010aa..65b8cba324be 100644 --- a/tools/perf/builtin-list.c +++ b/tools/perf/builtin-list.c @@ -173,7 +173,7 @@ static void default_print_event(void *ps, const char *pmu_name, const char *topi if (pmu_name && strcmp(pmu_name, "default_core")) { desc_len = strlen(desc); desc_len = asprintf(&desc_with_unit, - desc[desc_len - 1] != '.' + desc_len > 0 && desc[desc_len - 1] != '.' ? "%s. Unit: %s" : "%s Unit: %s", desc, pmu_name); }
If a desc string is 0 length then -1 will be out of bounds, add a check. Signed-off-by: Ian Rogers <irogers@google.com> --- tools/perf/builtin-list.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)