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