summaryrefslogtreecommitdiffstats
path: root/src/reply-password
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2018-10-15 13:58:31 +0200
committerLennart Poettering <lennart@poettering.net>2018-10-15 19:40:51 +0200
commit15a3e96f9220c931507456764902ff05d7171318 (patch)
treecd669f3363875fe1ee98a4bbcd77f1c27ca30f5e /src/reply-password
parentsocket-util: add sockaddr_un_set_path() helper (diff)
downloadsystemd-15a3e96f9220c931507456764902ff05d7171318.tar.xz
systemd-15a3e96f9220c931507456764902ff05d7171318.zip
tree-wide: port various users over to sockaddr_un_set_path()
CID 1396140 CID 1396141
Diffstat (limited to 'src/reply-password')
-rw-r--r--src/reply-password/reply-password.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/reply-password/reply-password.c b/src/reply-password/reply-password.c
index efb68a354f..84176184af 100644
--- a/src/reply-password/reply-password.c
+++ b/src/reply-password/reply-password.c
@@ -14,17 +14,18 @@
#include "util.h"
static int send_on_socket(int fd, const char *socket_name, const void *packet, size_t size) {
- union sockaddr_union sa = {
- .un.sun_family = AF_UNIX,
- };
+ union sockaddr_union sa = {};
+ int salen;
assert(fd >= 0);
assert(socket_name);
assert(packet);
- strncpy(sa.un.sun_path, socket_name, sizeof(sa.un.sun_path));
+ salen = sockaddr_un_set_path(&sa.un, socket_name);
+ if (salen < 0)
+ return log_error_errno(salen, "Specified socket path for AF_UNIX socket invalid, refusing: %s", socket_name);
- if (sendto(fd, packet, size, MSG_NOSIGNAL, &sa.sa, SOCKADDR_UN_LEN(sa.un)) < 0)
+ if (sendto(fd, packet, size, MSG_NOSIGNAL, &sa.sa, salen) < 0)
return log_error_errno(errno, "Failed to send: %m");
return 0;