X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Flibsystemd%2Fsd-daemon%2Fsd-daemon.c;fp=src%2Flibsystemd%2Fsd-daemon%2Fsd-daemon.c;h=0842aba9cbfa4ebcfe62c75532743ccb75fefbbd;hb=d4a144fadf89bca681724c6c9a65b4a165fa0f90;hp=c9e2f2dba83f4590a831134f276125df90d70f9b;hpb=c98a38ba0bbb7d64a9f4237157f2a08bb85615f6;p=elogind.git diff --git a/src/libsystemd/sd-daemon/sd-daemon.c b/src/libsystemd/sd-daemon/sd-daemon.c index c9e2f2dba..0842aba9c 100644 --- a/src/libsystemd/sd-daemon/sd-daemon.c +++ b/src/libsystemd/sd-daemon/sd-daemon.c @@ -350,11 +350,7 @@ _public_ int sd_pid_notify_with_fds(pid_t pid, int unset_environment, const char .msg_iovlen = 1, .msg_name = &sockaddr, }; - union { - struct cmsghdr cmsghdr; - uint8_t buf[CMSG_SPACE(sizeof(struct ucred)) + - CMSG_SPACE(sizeof(int) * n_fds)]; - } control; + struct cmsghdr *control; _cleanup_close_ int fd = -1; struct cmsghdr *cmsg = NULL; const char *e; @@ -398,8 +394,10 @@ _public_ int sd_pid_notify_with_fds(pid_t pid, int unset_environment, const char if (msghdr.msg_namelen > sizeof(struct sockaddr_un)) msghdr.msg_namelen = sizeof(struct sockaddr_un); + control = alloca(CMSG_SPACE(sizeof(struct ucred)) + CMSG_SPACE(sizeof(int) * n_fds)); + if (n_fds > 0) { - msghdr.msg_control = &control; + msghdr.msg_control = control; msghdr.msg_controllen = CMSG_LEN(sizeof(int) * n_fds); cmsg = CMSG_FIRSTHDR(&msghdr); @@ -416,7 +414,7 @@ _public_ int sd_pid_notify_with_fds(pid_t pid, int unset_environment, const char try_without_ucred = true; controllen_without_ucred = msghdr.msg_controllen; - msghdr.msg_control = &control; + msghdr.msg_control = control; msghdr.msg_controllen += CMSG_LEN(sizeof(struct ucred)); if (cmsg)