summaryrefslogtreecommitdiff
path: root/src/coredump
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2022-12-13 11:15:17 +0100
committerYu Watanabe <watanabe.yu+github@gmail.com>2022-12-14 01:37:19 +0900
commitc5966ab5bf43b4fb45998760beaffa6c7f9e8a9e (patch)
tree39c9530823188bde813f60f07a95a429a76d0f29 /src/coredump
parente4970f5dae9657ef18abeaf0990afb47bda407e2 (diff)
downloadsystemd-c5966ab5bf43b4fb45998760beaffa6c7f9e8a9e.tar.gz
coredump: cescape invalid json data before logging
In both cases, the json string is short, so we can print it, which is useful for diagnosing invalid data in packages. But we need escape non-printable characters. https://bugzilla.redhat.com/show_bug.cgi?id=2152685 I went over the rest of the codebase, and it seems that other calls to json_parse() don't have this problem.
Diffstat (limited to 'src/coredump')
-rw-r--r--src/coredump/coredumpctl.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/coredump/coredumpctl.c b/src/coredump/coredumpctl.c
index a6abcc6496..6a6a968149 100644
--- a/src/coredump/coredumpctl.c
+++ b/src/coredump/coredumpctl.c
@@ -19,6 +19,7 @@
#include "compress.h"
#include "constants.h"
#include "dissect-image.h"
+#include "escape.h"
#include "fd-util.h"
#include "format-table.h"
#include "fs-util.h"
@@ -790,9 +791,10 @@ static int print_info(FILE *file, sd_journal *j, bool need_space) {
_cleanup_(json_variant_unrefp) JsonVariant *v = NULL;
r = json_parse(pkgmeta_json, 0, &v, NULL, NULL);
- if (r < 0)
- log_warning_errno(r, "json_parse on %s failed, ignoring: %m", pkgmeta_json);
- else {
+ if (r < 0) {
+ _cleanup_free_ char *esc = cescape(pkgmeta_json);
+ log_warning_errno(r, "json_parse on \"%s\" failed, ignoring: %m", strnull(esc));
+ } else {
const char *module_name;
JsonVariant *module_json;