]> git.ipfire.org Git - thirdparty/systemd.git/commit - src/core/scope.c
core: rework serialization
authorLennart Poettering <lennart@poettering.net>
Wed, 17 Oct 2018 18:40:09 +0000 (20:40 +0200)
committerLennart Poettering <lennart@poettering.net>
Fri, 26 Oct 2018 08:52:41 +0000 (10:52 +0200)
commitd68c645bd3323ae1f0dfcb8fd74ea6b19681db8a
treeeff23147292bf0e0ee6066054b8e6e933ccd1b64
parentcdd620e3460b08d1f5b80cefefef352de42fb792
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.
31 files changed:
src/basic/env-util.c
src/basic/env-util.h
src/basic/exec-util.c
src/basic/time-util.c
src/basic/time-util.h
src/core/automount.c
src/core/dbus.c
src/core/device.c
src/core/dynamic-user.c
src/core/job.c
src/core/main.c
src/core/manager.c
src/core/mount.c
src/core/path.c
src/core/scope.c
src/core/service.c
src/core/slice.c
src/core/socket.c
src/core/swap.c
src/core/target.c
src/core/timer.c
src/core/unit.c
src/core/unit.h
src/login/logind-session.c
src/login/logind-user.c
src/machine/machine.c
src/shared/meson.build
src/shared/serialize.c [new file with mode: 0644]
src/shared/serialize.h [new file with mode: 0644]
src/test/test-env-util.c
src/test/test-time-util.c