int csock;
struct sockaddr_un saddr;
struct sockaddr_un caddr;
+ socklen_t addrlen;
socklen_t clen;
pthread_t cli_tid;
pthread_t mgr_msg_tid;
saddr.sun_family = AF_LOCAL;
/* use abstract namespace for socket path */
strcpy(&saddr.sun_path[1], UDEVD_SOCK_PATH);
+ addrlen = offsetof(struct sockaddr_un, sun_path) + strlen(saddr.sun_path+1) + 1;
ssock = socket(AF_LOCAL, SOCK_STREAM, 0);
if (ssock == -1) {
exit(1);
}
- retval = bind(ssock, &saddr, sizeof(saddr));
+ retval = bind(ssock, &saddr, addrlen);
if (retval < 0) {
dbg("bind failed\n");
goto exit;
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
+#include <stddef.h>
#include <string.h>
#include <unistd.h>
#include <time.h>
struct timespec tspec;
int sock;
struct sockaddr_un saddr;
+ socklen_t addrlen;
#ifdef DEBUG
init_logging("udevsend");
saddr.sun_family = AF_LOCAL;
/* use abstract namespace for socket path */
strcpy(&saddr.sun_path[1], UDEVD_SOCK_PATH);
+ addrlen = offsetof(struct sockaddr_un, sun_path) + strlen(saddr.sun_path+1) + 1;
/* try to connect, if it fails start daemon */
- retval = connect(sock, (struct sockaddr *) &saddr, sizeof(saddr));
+ retval = connect(sock, (struct sockaddr *) &saddr, addrlen);
if (retval != -1) {
goto send;
} else {