tracing: Change synthetic event string format to limit printed length

Change the format for printing synthetic field strings to limit the
length of the string printed even if it's not correctly terminated.

Link: https://lore.kernel.org/r/20201002210036.0200371b@oasis.local.home
Link: https://lkml.kernel.org/r/b6bdb34e70d970e8026daa3503db6b8e5cdad524.1601848695.git.zanussi@kernel.orgSigned-off-by: default avatarSteven Rostedt (VMware) <rostedt@goodmis.org>
parent cbcd9c83
...@@ -234,7 +234,7 @@ static const char *synth_field_fmt(char *type) ...@@ -234,7 +234,7 @@ static const char *synth_field_fmt(char *type)
else if (strcmp(type, "gfp_t") == 0) else if (strcmp(type, "gfp_t") == 0)
fmt = "%x"; fmt = "%x";
else if (synth_field_is_string(type)) else if (synth_field_is_string(type))
fmt = "%s"; fmt = "%.*s";
return fmt; return fmt;
} }
...@@ -303,11 +303,13 @@ static enum print_line_t print_synth_event(struct trace_iterator *iter, ...@@ -303,11 +303,13 @@ static enum print_line_t print_synth_event(struct trace_iterator *iter,
str_field = (char *)entry + data_offset; str_field = (char *)entry + data_offset;
trace_seq_printf(s, print_fmt, se->fields[i]->name, trace_seq_printf(s, print_fmt, se->fields[i]->name,
STR_VAR_LEN_MAX,
str_field, str_field,
i == se->n_fields - 1 ? "" : " "); i == se->n_fields - 1 ? "" : " ");
n_u64++; n_u64++;
} else { } else {
trace_seq_printf(s, print_fmt, se->fields[i]->name, trace_seq_printf(s, print_fmt, se->fields[i]->name,
STR_VAR_LEN_MAX,
(char *)&entry->fields[n_u64], (char *)&entry->fields[n_u64],
i == se->n_fields - 1 ? "" : " "); i == se->n_fields - 1 ? "" : " ");
n_u64 += STR_VAR_LEN_MAX / sizeof(u64); n_u64 += STR_VAR_LEN_MAX / sizeof(u64);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment