]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
image-policy: Fix strv size calculation
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Tue, 27 Aug 2024 13:26:20 +0000 (15:26 +0200)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Fri, 30 Aug 2024 10:12:53 +0000 (12:12 +0200)
We want the logarithm of the next power of two, which is the same
as the mask + 1, so add one to the mask to make sure the size is
sufficient to fit all flags.

src/shared/image-policy.c

index e7bd84e144164f28a1d0a5c323fc8c4bc562f23d..914dd0803911770c66dc4ae43bc5e5e9d9fcc983 100644 (file)
@@ -376,7 +376,7 @@ int image_policy_from_string(const char *s, ImagePolicy **ret) {
 
 int partition_policy_flags_to_string(PartitionPolicyFlags flags, bool simplify, char **ret) {
         _cleanup_free_ char *buf = NULL;
-        const char *l[CONST_LOG2U(_PARTITION_POLICY_MASK) + 1]; /* one string per known flag at most */
+        const char *l[CONST_LOG2U(_PARTITION_POLICY_MASK + 1) + 1]; /* one string per known flag at most */
         size_t m = 0;
 
         assert(ret);