Skip to content

Commit

Permalink
systemctl: explicitly cast the constants to uint64_t
Browse files Browse the repository at this point in the history
Otherwise under certain conditions `va_arg()` might get garbage instead
of the expected value, i.e.:

$ sudo build-o0/systemctl disable asdfasfaf
sd_bus_message_appendv: Got uint64_t: 0
Failed to disable unit: Unit file asdfasfaf.service does not exist.

$ sudo build-o1/systemctl disable asdfasfaf
sd_bus_message_appendv: Got uint64_t: 7954875719681572864
Failed to disable unit: Invalid argument

(reproduced on an armv7hl machine)

Resolves: #26568
Follow-up to: bf1bea4
Related issue: #14470 (comment)
  • Loading branch information
mrc0mmand authored and bluca committed Mar 3, 2023
1 parent 0c70d5e commit c63bfd0
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/systemctl/systemctl-enable.c
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ int verb_enable(int argc, char *argv[], void *userdata) {

if (send_runtime) {
if (streq(method, "DisableUnitFilesWithFlagsAndInstallInfo"))
r = sd_bus_message_append(m, "t", arg_runtime ? UNIT_FILE_RUNTIME : 0);
r = sd_bus_message_append(m, "t", arg_runtime ? (uint64_t) UNIT_FILE_RUNTIME : UINT64_C(0));
else
r = sd_bus_message_append(m, "b", arg_runtime);
if (r < 0)
Expand Down

0 comments on commit c63bfd0

Please sign in to comment.