From 6f3d68bc8b46bdc7b0f5f43918744d99746672a2 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Mon, 27 Feb 2023 09:38:22 +0100 Subject: 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. --- libstore/zero.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'libstore') 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); } } -- cgit v1.2.3