From: Luca Boccassi Date: Sat, 28 Mar 2026 20:13:40 +0000 (+0000) Subject: exec-util: use unsigned shift for ExecCommandFlags X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=3e38052f1ddda29ee0d7b8a235fd9bebc39774c0;p=thirdparty%2Fsystemd.git exec-util: use unsigned shift for ExecCommandFlags Using signed int literal '1' in left shift operations can theoretically lead to undefined behavior. Use 1U to be explicit about unsigned arithmetic. CID#1548018 Follow-up for b3d593673c5b8b0b7d781fd26ab2062ca6e7dbdb --- diff --git a/src/shared/exec-util.c b/src/shared/exec-util.c index 2e15f311b88..420803c77d4 100644 --- a/src/shared/exec-util.c +++ b/src/shared/exec-util.c @@ -500,7 +500,7 @@ assert_cc((1 << ELEMENTSOF(exec_command_strings)) - 1 == _EXEC_COMMAND_FLAGS_ALL const char* exec_command_flags_to_string(ExecCommandFlags i) { for (size_t idx = 0; idx < ELEMENTSOF(exec_command_strings); idx++) - if (i == (1 << idx)) + if (i == (ExecCommandFlags) (1U << idx)) return exec_command_strings[idx]; return NULL; @@ -516,7 +516,7 @@ ExecCommandFlags exec_command_flags_from_string(const char *s) { if (idx < 0) return _EXEC_COMMAND_FLAGS_INVALID; - return 1 << idx; + return 1U << idx; } int fexecve_or_execve(int executable_fd, const char *executable, char *const argv[], char *const envp[]) {