Skip to content

Commit d3d5c1a

Browse files
captain5050acmel
authored andcommitted
perf list: Avoid potential out of bounds memory read
If a desc string is 0 length then -1 will be out of bounds, add a check. Signed-off-by: Ian Rogers <[email protected]> Cc: Adrian Hunter <[email protected]> Cc: Alexander Shishkin <[email protected]> Cc: Andi Kleen <[email protected]> Cc: Athira Rajeev <[email protected]> Cc: Benjamin Gray <[email protected]> Cc: Changbin Du <[email protected]> Cc: Clément Le Goffic <[email protected]> Cc: Colin Ian King <[email protected]> Cc: Dominique Martinet <[email protected]> Cc: Dr. David Alan Gilbert <[email protected]> Cc: Howard Chu <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: James Clark <[email protected]> Cc: Jing Zhang <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: John Garry <[email protected]> Cc: Junhao He <[email protected]> Cc: Kan Liang <[email protected]> Cc: Leo Yan <[email protected]> Cc: Mark Rutland <[email protected]> Cc: Mike Leach <[email protected]> Cc: Namhyung Kim <[email protected]> Cc: Oliver Upton <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Ravi Bangoria <[email protected]> Cc: Sandipan Das <[email protected]> Cc: Sun Haiyong <[email protected]> Cc: Tiezhu Yang <[email protected]> Cc: Veronika Molnarova <[email protected]> Cc: Weilin Wang <[email protected]> Cc: Will Deacon <[email protected]> Cc: Xu Yang <[email protected]> Cc: Yang Jihong <[email protected]> Cc: Yicong Yang <[email protected]> Cc: Ze Gao <[email protected]> Cc: [email protected] Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent 4ae354d commit d3d5c1a

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

tools/perf/builtin-list.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ static void default_print_event(void *ps, const char *pmu_name, const char *topi
173173
if (pmu_name && strcmp(pmu_name, "default_core")) {
174174
desc_len = strlen(desc);
175175
desc_len = asprintf(&desc_with_unit,
176-
desc[desc_len - 1] != '.'
176+
desc_len > 0 && desc[desc_len - 1] != '.'
177177
? "%s. Unit: %s" : "%s Unit: %s",
178178
desc, pmu_name);
179179
}

0 commit comments

Comments
 (0)