diff options
author | Lennart Poettering <lennart@poettering.net> | 2016-05-05 22:24:36 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2016-05-05 22:24:36 +0200 |
commit | fc2fffe7706ef269005bf4eef56570346c9ca3da (patch) | |
tree | 9e89ac76ee15de498d97b0d03ed7d764b61874ce /src/core/dbus.c | |
parent | d8fdc62037b5b0a9fd603ad5efd6b49f956f86b5 (diff) |
tree-wide: introduce new SOCKADDR_UN_LEN() macro, and use it everywhere
The macro determines the right length of a AF_UNIX "struct sockaddr_un" to pass to
connect() or bind(). It automatically figures out if the socket refers to an
abstract namespace socket, or a socket in the file system, and properly handles
the full length of the path field.
This macro is not only safer, but also simpler to use, than the usual
offsetof() + strlen() logic.
Diffstat (limited to 'src/core/dbus.c')
-rw-r--r-- | src/core/dbus.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/core/dbus.c b/src/core/dbus.c index c8375a0475..3422a02d68 100644 --- a/src/core/dbus.c +++ b/src/core/dbus.c @@ -975,7 +975,7 @@ static int bus_init_private(Manager *m) { return 0; strcpy(sa.un.sun_path, "/run/systemd/private"); - salen = offsetof(union sockaddr_union, un.sun_path) + strlen("/run/systemd/private"); + salen = SOCKADDR_UN_LEN(sa.un); } else { size_t left = sizeof(sa.un.sun_path); char *p = sa.un.sun_path; |