summaryrefslogtreecommitdiff
path: root/src/libsystemd
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2014-11-10 20:54:45 +0100
committerLennart Poettering <lennart@poettering.net>2014-11-10 20:54:45 +0100
commit27e9c5af817147ea1c678769e45e83f2e4b4ae96 (patch)
tree6121fb1a1d6b3f47d8bc7e4c03c666ded6f637c7 /src/libsystemd
parentc73d180dc4bbd87c945a524b42b672af2ffe2609 (diff)
bus: when dumping string property values escape the chars we use as end-of-line and end-of-item marks
Diffstat (limited to 'src/libsystemd')
-rw-r--r--src/libsystemd/sd-bus/bus-util.c19
1 files changed, 16 insertions, 3 deletions
diff --git a/src/libsystemd/sd-bus/bus-util.c b/src/libsystemd/sd-bus/bus-util.c
index 43acf5b959..5345526309 100644
--- a/src/libsystemd/sd-bus/bus-util.c
+++ b/src/libsystemd/sd-bus/bus-util.c
@@ -640,8 +640,15 @@ int bus_print_property(const char *name, sd_bus_message *property, bool all) {
if (r < 0)
return r;
- if (all || !isempty(s))
- printf("%s=%s\n", name, s);
+ if (all || !isempty(s)) {
+ _cleanup_free_ char *escaped = NULL;
+
+ escaped = xescape(s, "\n");
+ if (!escaped)
+ return -ENOMEM;
+
+ printf("%s=%s\n", name, escaped);
+ }
return 1;
}
@@ -732,10 +739,16 @@ int bus_print_property(const char *name, sd_bus_message *property, bool all) {
return r;
while((r = sd_bus_message_read_basic(property, SD_BUS_TYPE_STRING, &str)) > 0) {
+ _cleanup_free_ char *escaped = NULL;
+
if (first)
printf("%s=", name);
- printf("%s%s", first ? "" : " ", str);
+ escaped = xescape(str, "\n ");
+ if (!escaped)
+ return -ENOMEM;
+
+ printf("%s%s", first ? "" : " ", escaped);
first = false;
}