From 0edb6165b58950a4ae1f8d550b96ba889275df92 Mon Sep 17 00:00:00 2001 From: Patrick Pelissier Date: Sat, 13 Mar 2021 23:39:26 +0100 Subject: [PATCH] Fix buffer overflow if size=64*N --- m-bitset.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/m-bitset.h b/m-bitset.h index bb82d353..41e7b192 100644 --- a/m-bitset.h +++ b/m-bitset.h @@ -269,13 +269,12 @@ bitset_resize (bitset_t v, size_t size) } else if (size > old_size) { // Resize up the bitset: set to 0 new bits. const size_t old_offset = old_size / M_B1TSET_LIMB_BIT; - for(size_t i = old_offset+1 ; i <= offset; i++) { + for(size_t i = old_offset+1 ; i < offset; i++) { v->ptr[i] = 0; } if (M_LIKELY(index != 0)) { // Mask the last limb to clear the last bits - // Needed only if old_offset == offset - v->ptr[offset] &= mask; + v->ptr[offset] = 0; } } v->size = size;