summaryrefslogtreecommitdiff
path: root/libstore
diff options
context:
space:
mode:
authorSamuel Thibault <samuel.thibault@ens-lyon.org>2023-02-27 09:38:22 +0100
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2023-02-27 09:38:22 +0100
commit6f3d68bc8b46bdc7b0f5f43918744d99746672a2 (patch)
treed9365811470b28b313e78da59c6f44d75309983d /libstore
parent78a45f762d19b6b3079951f471f8811744f2bd81 (diff)
libstore: Fix zero store size computation
56d065041793 ("libstore: Fix undefined behavior") missed letting the sign bit be 0, thus leading to a negative store size, and thus /dev/zero would reject any read/write.
Diffstat (limited to 'libstore')
-rw-r--r--libstore/zero.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/libstore/zero.c b/libstore/zero.c
index 2960c18a..b35d29a5 100644
--- a/libstore/zero.c
+++ b/libstore/zero.c
@@ -150,8 +150,9 @@ zero_open (const char *name, int flags,
}
else
{
- store_offset_t max_offs = ~((store_offset_t)1
- << (CHAR_BIT * sizeof (store_offset_t) - 2));
+ store_offset_t max_offs = (
+ ((store_offset_t)1 << (CHAR_BIT * sizeof (store_offset_t) - 2))
+ - 1) * 2 + 1;
return store_zero_create (max_offs, flags, store);
}
}