From: Namhyung Kim Date: Mon, 12 Jun 2023 23:41:01 +0000 (-0700) Subject: perf dwarf-aux: Fix off-by-one in die_get_varname() X-Git-Tag: v6.6.17~4410^2~109 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=3abfcfd847717d232e36963f31a361747c388fe7;p=platform%2Fkernel%2Flinux-rpi.git perf dwarf-aux: Fix off-by-one in die_get_varname() The die_get_varname() returns "(unknown_type)" string if it failed to find a type for the variable. But it had a space before the opening parenthesis and it made the closing parenthesis cut off due to the off-by-one in the string length (14). Signed-off-by: Namhyung Kim Fixes: 88fd633cdfa19060 ("perf probe: No need to use formatting strbuf method") Cc: Adrian Hunter Cc: Ian Rogers Cc: Ingo Molnar Cc: Jiri Olsa Cc: Masami Hiramatsu Cc: Peter Zijlstra Link: https://lore.kernel.org/r/20230612234102.3909116-1-namhyung@kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- diff --git a/tools/perf/util/dwarf-aux.c b/tools/perf/util/dwarf-aux.c index b0741440..3bff678 100644 --- a/tools/perf/util/dwarf-aux.c +++ b/tools/perf/util/dwarf-aux.c @@ -1103,7 +1103,7 @@ int die_get_varname(Dwarf_Die *vr_die, struct strbuf *buf) ret = die_get_typename(vr_die, buf); if (ret < 0) { pr_debug("Failed to get type, make it unknown.\n"); - ret = strbuf_add(buf, " (unknown_type)", 14); + ret = strbuf_add(buf, "(unknown_type)", 14); } return ret < 0 ? ret : strbuf_addf(buf, "\t%s", dwarf_diename(vr_die));