summaryrefslogtreecommitdiff
path: root/src/cgroups-agent
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2016-05-05 22:24:36 +0200
committerLennart Poettering <lennart@poettering.net>2016-05-05 22:24:36 +0200
commitfc2fffe7706ef269005bf4eef56570346c9ca3da (patch)
tree9e89ac76ee15de498d97b0d03ed7d764b61874ce /src/cgroups-agent
parentd8fdc62037b5b0a9fd603ad5efd6b49f956f86b5 (diff)
downloadsystemd-fc2fffe7706ef269005bf4eef56570346c9ca3da.tar.gz
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/cgroups-agent')
-rw-r--r--src/cgroups-agent/cgroups-agent.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/cgroups-agent/cgroups-agent.c b/src/cgroups-agent/cgroups-agent.c
index 333ce110d3..d7c722ac3d 100644
--- a/src/cgroups-agent/cgroups-agent.c
+++ b/src/cgroups-agent/cgroups-agent.c
@@ -52,7 +52,7 @@ int main(int argc, char *argv[]) {
l = strlen(argv[1]);
- n = sendto(fd, argv[1], l, 0, &sa.sa, offsetof(struct sockaddr_un, sun_path) + strlen(sa.un.sun_path));
+ n = sendto(fd, argv[1], l, 0, &sa.sa, SOCKADDR_UN_LEN(sa.un));
if (n < 0) {
log_debug_errno(errno, "Failed to send cgroups agent message: %m");
return EXIT_FAILURE;