blob: d840de870f2e14b4b84ca2a89783f30d56ea3439 [file] [log] [blame]
Andrew Geisslerfc113ea2023-03-31 09:59:46 -05001From fad29ce1f5cc7b12bc13671d9ad80775771a67eb Mon Sep 17 00:00:00 2001
2From: Frantisek Sumsal <frantisek@sumsal.cz>
3Date: Fri, 3 Mar 2023 12:17:27 +0100
4Subject: [PATCH] systemctl: explicitly cast the constants to uint64_t
5
6Otherwise under certain conditions `va_arg()` might get garbage instead
7of the expected value, i.e.:
8
9$ sudo build-o0/systemctl disable asdfasfaf
10sd_bus_message_appendv: Got uint64_t: 0
11Failed to disable unit: Unit file asdfasfaf.service does not exist.
12
13$ sudo build-o1/systemctl disable asdfasfaf
14sd_bus_message_appendv: Got uint64_t: 7954875719681572864
15Failed to disable unit: Invalid argument
16
17(reproduced on an armv7hl machine)
18
19Resolves: #26568
20Follow-up to: bf1bea43f15
21Related issue: https://github.com/systemd/systemd/pull/14470#discussion_r362893735
22
23Upstream-Status: Backport [https://github.com/systemd/systemd/commit/c63bfd0884cf20e48befbee49d41f667660a8802]
24Signed-off-by: Alexander Kanavin <alex@linutronix.de>
25---
26 src/systemctl/systemctl-enable.c | 2 +-
27 1 file changed, 1 insertion(+), 1 deletion(-)
28
29diff --git a/src/systemctl/systemctl-enable.c b/src/systemctl/systemctl-enable.c
30index 86d9f602fa..f94a286122 100644
31--- a/src/systemctl/systemctl-enable.c
32+++ b/src/systemctl/systemctl-enable.c
33@@ -211,7 +211,7 @@ int verb_enable(int argc, char *argv[], void *userdata) {
34
35 if (send_runtime) {
36 if (streq(method, "DisableUnitFilesWithFlagsAndInstallInfo"))
37- r = sd_bus_message_append(m, "t", arg_runtime ? UNIT_FILE_RUNTIME : 0);
38+ r = sd_bus_message_append(m, "t", arg_runtime ? (uint64_t) UNIT_FILE_RUNTIME : UINT64_C(0));
39 else
40 r = sd_bus_message_append(m, "b", arg_runtime);
41 if (r < 0)
42--
432.39.2
44