summaryrefslogtreecommitdiff
path: root/src/core/dbus.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2018-10-17 20:40:09 +0200
committerLennart Poettering <lennart@poettering.net>2018-10-26 10:52:41 +0200
commitd68c645bd3323ae1f0dfcb8fd74ea6b19681db8a (patch)
treeeff23147292bf0e0ee6066054b8e6e933ccd1b64 /src/core/dbus.c
parentcdd620e3460b08d1f5b80cefefef352de42fb792 (diff)
downloadsystemd-d68c645bd3323ae1f0dfcb8fd74ea6b19681db8a.tar.gz
core: rework serialization
Let's be more careful with what we serialize: let's ensure we never serialize strings that are longer than LONG_LINE_MAX, so that we know we can read them back with read_line(…, LONG_LINE_MAX, …) safely. In order to implement this all serialization functions are move to serialize.[ch], and internally will do line size checks. We'd rather skip a serialization line (with a loud warning) than write an overly long line out. Of course, this is just a second level protection, after all the data we serialize shouldn't be this long in the first place. While we are at it also clean up logging: while serializing make sure to always log about errors immediately. Also, (void)ify all calls we don't expect errors in (or catch errors as part of the general fflush_and_check() at the end.
Diffstat (limited to 'src/core/dbus.c')
-rw-r--r--src/core/dbus.c10
1 files changed, 3 insertions, 7 deletions
diff --git a/src/core/dbus.c b/src/core/dbus.c
index 3ffb53cb6e..c2f77b8eef 100644
--- a/src/core/dbus.c
+++ b/src/core/dbus.c
@@ -36,6 +36,7 @@
#include "mkdir.h"
#include "process-util.h"
#include "selinux-access.h"
+#include "serialize.h"
#include "service.h"
#include "special.h"
#include "string-util.h"
@@ -1204,13 +1205,8 @@ void bus_track_serialize(sd_bus_track *t, FILE *f, const char *prefix) {
int c, j;
c = sd_bus_track_count_name(t, n);
-
- for (j = 0; j < c; j++) {
- fputs(prefix, f);
- fputc('=', f);
- fputs(n, f);
- fputc('\n', f);
- }
+ for (j = 0; j < c; j++)
+ (void) serialize_item(f, prefix, n);
}
}