daandemeyer / rpms / systemd

Forked from rpms/systemd 2 years ago
Clone
923a60
From 529c94b47f886f99796cff0f5827d6c2ebdcea19 Mon Sep 17 00:00:00 2001
923a60
From: Lennart Poettering <lennart@poettering.net>
923a60
Date: Mon, 2 Mar 2015 20:55:38 +0100
923a60
Subject: [PATCH] sd-daemon: replace VLA with alloca(), to make llvm happy
923a60
923a60
https://bugs.freedesktop.org/show_bug.cgi?id=89379
923a60
(cherry picked from commit d4a144fadf89bca681724c6c9a65b4a165fa0f90)
923a60
---
923a60
 src/libsystemd/sd-daemon/sd-daemon.c | 12 +++++-------
923a60
 1 file changed, 5 insertions(+), 7 deletions(-)
923a60
923a60
diff --git a/src/libsystemd/sd-daemon/sd-daemon.c b/src/libsystemd/sd-daemon/sd-daemon.c
923a60
index 028c2a7a5b..22a3a5347a 100644
923a60
--- a/src/libsystemd/sd-daemon/sd-daemon.c
923a60
+++ b/src/libsystemd/sd-daemon/sd-daemon.c
923a60
@@ -352,11 +352,7 @@ _public_ int sd_pid_notify_with_fds(pid_t pid, int unset_environment, const char
923a60
                 .msg_iovlen = 1,
923a60
                 .msg_name = &sockaddr,
923a60
         };
923a60
-        union {
923a60
-                struct cmsghdr cmsghdr;
923a60
-                uint8_t buf[CMSG_SPACE(sizeof(struct ucred)) +
923a60
-                            CMSG_SPACE(sizeof(int) * n_fds)];
923a60
-        } control;
923a60
+        struct cmsghdr *control;
923a60
         _cleanup_close_ int fd = -1;
923a60
         struct cmsghdr *cmsg = NULL;
923a60
         const char *e;
923a60
@@ -400,8 +396,10 @@ _public_ int sd_pid_notify_with_fds(pid_t pid, int unset_environment, const char
923a60
         if (msghdr.msg_namelen > sizeof(struct sockaddr_un))
923a60
                 msghdr.msg_namelen = sizeof(struct sockaddr_un);
923a60
 
923a60
+        control = alloca(CMSG_SPACE(sizeof(struct ucred)) + CMSG_SPACE(sizeof(int) * n_fds));
923a60
+
923a60
         if (n_fds > 0) {
923a60
-                msghdr.msg_control = &control;
923a60
+                msghdr.msg_control = control;
923a60
                 msghdr.msg_controllen = CMSG_LEN(sizeof(int) * n_fds);
923a60
 
923a60
                 cmsg = CMSG_FIRSTHDR(&msghdr);
923a60
@@ -418,7 +416,7 @@ _public_ int sd_pid_notify_with_fds(pid_t pid, int unset_environment, const char
923a60
                 try_without_ucred = true;
923a60
                 controllen_without_ucred = msghdr.msg_controllen;
923a60
 
923a60
-                msghdr.msg_control = &control;
923a60
+                msghdr.msg_control = control;
923a60
                 msghdr.msg_controllen += CMSG_LEN(sizeof(struct ucred));
923a60
 
923a60
                 if (cmsg)