else
strncpy(sa.un.sun_path+1, NOTIFY_SOCKET, sizeof(sa.un.sun_path)-1);
- if (bind(m->notify_watch.fd, &sa.sa, sizeof(sa)) < 0) {
+ if (bind(m->notify_watch.fd, &sa.sa, sizeof(sa_family_t) + 1 + strlen(sa.un.sun_path+1)) < 0) {
log_error("bind() failed: %m");
return -errno;
}
a->sockaddr.un.sun_family = AF_UNIX;
memcpy(a->sockaddr.un.sun_path+1, s+1, l);
- a->size = sizeof(struct sockaddr_un);
+ a->size = sizeof(sa_family_t) + 1 + l;
} else {
if (a->size > sizeof(sa_family_t)) {
- if (a->sockaddr.un.sun_path[0] == 0) {
- /* abstract */
- if (a->size != sizeof(struct sockaddr_un))
- return -EINVAL;
- } else {
+ if (a->sockaddr.un.sun_path[0] != 0) {
char *e;
/* path */
if (strncmp(a->sockaddr.un.sun_path, b->sockaddr.un.sun_path, sizeof(a->sockaddr.un.sun_path)) != 0)
return false;
} else {
- if (memcmp(a->sockaddr.un.sun_path, b->sockaddr.un.sun_path, sizeof(a->sockaddr.un.sun_path)) != 0)
+ if (memcmp(a->sockaddr.un.sun_path, b->sockaddr.un.sun_path, a->size) != 0)
return false;
}