History

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.org

Steven Rostedt (VMware) committed 6 years ago

Commit 8db4d6b1 parent cbcd9c81 file · +3 −1Browse files

Unified · Split

kernel/trace/trace_events_synth.c+3−1
@@ -234,7 +234,7 @@ static const char *synth_field_fmt(char *type) · 233 unmodified lines
234234 else if (strcmp(type, "gfp_t") == 0)
235235 fmt = "%x";
236236 else if (synth_field_is_string(type))
237− fmt = "%s";
237+ fmt = "%.*s";
238238
239239 return fmt;
240240 }
@@ -303,11 +303,13 @@ static enum print_line_t print_synth_event(struct trace_iterator *iter, · 62 unmodified lines
303303 str_field = (char *)entry + data_offset;
304304
305305 trace_seq_printf(s, print_fmt, se->fields[i]->name,
306+ STR_VAR_LEN_MAX,
306307 str_field,
307308 i == se->n_fields - 1 ? "" : " ");
308309 n_u64++;
309310 } else {
310311 trace_seq_printf(s, print_fmt, se->fields[i]->name,
312+ STR_VAR_LEN_MAX,
311313 (char *)&entry->fields[n_u64],
312314 i == se->n_fields - 1 ? "" : " ");
313315 n_u64 += STR_VAR_LEN_MAX / sizeof(u64);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t