From 56d065041793509a6f60671f6ae3400698bd5639 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Fri, 10 Feb 2023 19:20:43 +0100 Subject: libstore: Fix undefined behavior store_offset_t is a signed type, so 1 << (bits-1) overflows. --- libstore/zero.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'libstore') diff --git a/libstore/zero.c b/libstore/zero.c index 878b2271..2960c18a 100644 --- a/libstore/zero.c +++ b/libstore/zero.c @@ -151,7 +151,7 @@ zero_open (const char *name, int flags, else { store_offset_t max_offs = ~((store_offset_t)1 - << (CHAR_BIT * sizeof (store_offset_t) - 1)); + << (CHAR_BIT * sizeof (store_offset_t) - 2)); return store_zero_create (max_offs, flags, store); } } -- cgit v1.2.3