]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: stats-file: use explicit unsigned integer bitshift for user slots
authorAurelien DARRAGON <adarragon@haproxy.com>
Mon, 8 Sep 2025 09:25:39 +0000 (11:25 +0200)
committerWilly Tarreau <w@1wt.eu>
Mon, 8 Sep 2025 11:38:49 +0000 (13:38 +0200)
As reported in GH #3104, there remained a place where (1 << shift was
used to set or remove bits from uint64_t users bitfield. It is incorrect
and could lead to bugs for values > 32 bits.

Instead, let's use 1ULL to ensure the operation remains 64bits consistent.

No backport needed.

src/stats-file.c

index 4f74c3062c7e2e3383557d706ca971c047e4bbff..578646cd2a8ec36ba8a20a889591afe777138b9c 100644 (file)
@@ -566,7 +566,7 @@ static struct shm_stats_file_object *shm_stats_file_reuse_object(void)
                        free = 1; // consider all users are inactive for now
 
                        while (slot < sizeof(shm_stats_file_hdr->slots) / sizeof(shm_stats_file_hdr->slots[0])) {
-                               if ((users & (1 << slot)) &&
+                               if ((users & (1ULL << slot)) &&
                                    !shm_stats_file_slot_isfree(shm_stats_file_hdr, slot)) {
                                        /* user still alive, so supposedly making use of it */
                                        free = 0;