summaryrefslogtreecommitdiff
path: root/src/coredump
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2019-05-15 11:20:26 +0200
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2019-05-22 10:08:17 +0200
commitbc28751ed2372065fd6f6f7ba6137edf21dee88b (patch)
tree22b55bbd88ec30c99aafc0fbb671ce965f621632 /src/coredump
parentda88f542d9315a341a500897e5e1bf8809d1aeae (diff)
downloadsystemd-bc28751ed2372065fd6f6f7ba6137edf21dee88b.tar.gz
Rework cmdline printing to use unicode
The functions to retrieve and print process cmdlines were based on the assumption that they contain printable ASCII, and everything else should be filtered out. That assumption doesn't hold in today's world, where people are free to use unicode everywhere. This replaces the custom cmdline reading code with a more generic approach using utf8_escape_non_printable_full(). For kernel threads, truncation is done on the parenthesized name, so we'll get "[worker]", "[worker…]", …, "[w…]", "[…", "…" as we reduce the number of available columns. This implementation is most likely slower for very long cmdlines, but I don't think this is very important. The common case is to have short commandlines, and should print those properly. Absurdly long cmdlines are the exception, which needs to be handled correctly and safely, but speed is not too important. Fixes #12532. v2: - use size_t for the number of columns. This change propagates into various other functions that call get_process_cmdline(), increasing the size of the patch, but the changes are rather trivial.
Diffstat (limited to 'src/coredump')
-rw-r--r--src/coredump/coredump.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/coredump/coredump.c b/src/coredump/coredump.c
index 9ab704e207..c0bd03762f 100644
--- a/src/coredump/coredump.c
+++ b/src/coredump/coredump.c
@@ -661,7 +661,7 @@ static int get_process_container_parent_cmdline(pid_t pid, char** cmdline) {
if (r < 0)
return r;
- r = get_process_cmdline(container_pid, 0, false, cmdline);
+ r = get_process_cmdline(container_pid, SIZE_MAX, false, cmdline);
if (r < 0)
return r;
@@ -1154,7 +1154,7 @@ static int gather_pid_metadata(
if (sd_pid_get_slice(pid, &t) >= 0)
set_iovec_field_free(iovec, n_iovec, "COREDUMP_SLICE=", t);
- if (get_process_cmdline(pid, 0, false, &t) >= 0)
+ if (get_process_cmdline(pid, SIZE_MAX, false, &t) >= 0)
set_iovec_field_free(iovec, n_iovec, "COREDUMP_CMDLINE=", t);
if (cg_pid_get_path_shifted(pid, NULL, &t) >= 0)