aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/scripting-engines/trace-event-python.c
diff options
context:
space:
mode:
authorIan Rogers <[email protected]>2025-07-24 16:32:43 +0000
committerNamhyung Kim <[email protected]>2025-07-25 17:37:13 +0000
commitfccaaf6fbbc59910edcf276f97a5b2ef5778c55e (patch)
tree9ec308fd5994e50fddb58ddf58f963d88eafbda7 /tools/perf/util/scripting-engines/trace-event-python.c
parentperf build-id: Truncate to avoid overflowing the build_id data (diff)
downloadkernel-fccaaf6fbbc59910edcf276f97a5b2ef5778c55e.tar.gz
kernel-fccaaf6fbbc59910edcf276f97a5b2ef5778c55e.zip
perf build-id: Change sprintf functions to snprintf
Pass in a size argument rather than implying all build id strings must be SBUILD_ID_SIZE. Signed-off-by: Ian Rogers <[email protected]> Link: https://lore.kernel.org/r/[email protected] [ fixed some build errors ] Signed-off-by: Namhyung Kim <[email protected]>
Diffstat (limited to 'tools/perf/util/scripting-engines/trace-event-python.c')
-rw-r--r--tools/perf/util/scripting-engines/trace-event-python.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/tools/perf/util/scripting-engines/trace-event-python.c b/tools/perf/util/scripting-engines/trace-event-python.c
index 00f2c6c5114d..6655c0bbe0d8 100644
--- a/tools/perf/util/scripting-engines/trace-event-python.c
+++ b/tools/perf/util/scripting-engines/trace-event-python.c
@@ -780,14 +780,13 @@ static void set_sym_in_dict(PyObject *dict, struct addr_location *al,
const char *sym_field, const char *symoff_field,
const char *map_pgoff)
{
- char sbuild_id[SBUILD_ID_SIZE];
-
if (al->map) {
+ char sbuild_id[SBUILD_ID_SIZE];
struct dso *dso = map__dso(al->map);
pydict_set_item_string_decref(dict, dso_field,
_PyUnicode_FromString(dso__name(dso)));
- build_id__sprintf(dso__bid(dso), sbuild_id);
+ build_id__snprintf(dso__bid(dso), sbuild_id, sizeof(sbuild_id));
pydict_set_item_string_decref(dict, dso_bid_field,
_PyUnicode_FromString(sbuild_id));
pydict_set_item_string_decref(dict, dso_map_start,
@@ -1238,7 +1237,7 @@ static int python_export_dso(struct db_export *dbe, struct dso *dso,
char sbuild_id[SBUILD_ID_SIZE];
PyObject *t;
- build_id__sprintf(dso__bid(dso), sbuild_id);
+ build_id__snprintf(dso__bid(dso), sbuild_id, sizeof(sbuild_id));
t = tuple_new(5);