Andrew Geissler | fc113ea | 2023-03-31 09:59:46 -0500 | [diff] [blame] | 1 | From fad29ce1f5cc7b12bc13671d9ad80775771a67eb Mon Sep 17 00:00:00 2001 |
| 2 | From: Frantisek Sumsal <frantisek@sumsal.cz> |
| 3 | Date: Fri, 3 Mar 2023 12:17:27 +0100 |
| 4 | Subject: [PATCH] systemctl: explicitly cast the constants to uint64_t |
| 5 | |
| 6 | Otherwise under certain conditions `va_arg()` might get garbage instead |
| 7 | of the expected value, i.e.: |
| 8 | |
| 9 | $ sudo build-o0/systemctl disable asdfasfaf |
| 10 | sd_bus_message_appendv: Got uint64_t: 0 |
| 11 | Failed to disable unit: Unit file asdfasfaf.service does not exist. |
| 12 | |
| 13 | $ sudo build-o1/systemctl disable asdfasfaf |
| 14 | sd_bus_message_appendv: Got uint64_t: 7954875719681572864 |
| 15 | Failed to disable unit: Invalid argument |
| 16 | |
| 17 | (reproduced on an armv7hl machine) |
| 18 | |
| 19 | Resolves: #26568 |
| 20 | Follow-up to: bf1bea43f15 |
| 21 | Related issue: https://github.com/systemd/systemd/pull/14470#discussion_r362893735 |
| 22 | |
| 23 | Upstream-Status: Backport [https://github.com/systemd/systemd/commit/c63bfd0884cf20e48befbee49d41f667660a8802] |
| 24 | Signed-off-by: Alexander Kanavin <alex@linutronix.de> |
| 25 | --- |
| 26 | src/systemctl/systemctl-enable.c | 2 +- |
| 27 | 1 file changed, 1 insertion(+), 1 deletion(-) |
| 28 | |
| 29 | diff --git a/src/systemctl/systemctl-enable.c b/src/systemctl/systemctl-enable.c |
| 30 | index 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 | -- |
| 43 | 2.39.2 |
| 44 | |