diff options
author | Lennart Poettering <lennart@poettering.net> | 2010-10-07 02:34:17 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2010-10-07 02:34:17 +0200 |
commit | 0e098b15c76e222f7de381203c0c35a75a5b2f24 (patch) | |
tree | 864b2b06696c7fcc4d0c29daa3121574c52f004b /src/reply-password.c | |
parent | e983b76024342278a0377eae116c925f2567776e (diff) |
util: never use sizeof(sa_family_t) when calculating sockaddr sizes
Diffstat (limited to 'src/reply-password.c')
-rw-r--r-- | src/reply-password.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/reply-password.c b/src/reply-password.c index 236fdcc94c..24d73a798e 100644 --- a/src/reply-password.c +++ b/src/reply-password.c @@ -31,6 +31,7 @@ #include <sys/stat.h> #include <sys/signalfd.h> #include <getopt.h> +#include <stddef.h> #include "log.h" #include "macro.h" @@ -50,7 +51,7 @@ static int send_on_socket(int fd, const char *socket_name, const void *packet, s sa.un.sun_family = AF_UNIX; strncpy(sa.un.sun_path+1, socket_name, sizeof(sa.un.sun_path)-1); - if (sendto(fd, packet, size, MSG_NOSIGNAL, &sa.sa, sizeof(sa_family_t) + 1 + strlen(socket_name)) < 0) { + if (sendto(fd, packet, size, MSG_NOSIGNAL, &sa.sa, offsetof(struct sockaddr_un, sun_path) + 1 + strlen(socket_name)) < 0) { log_error("Failed to send: %m"); return -1; } |