From c2541d65c8d439fa1562bf8f65cdbdf97388f507 Mon Sep 17 00:00:00 2001 From: Connor Abbott Date: Mon, 10 Jan 2022 14:01:34 +0100 Subject: [PATCH] util/bitset: Fix off-by-one in __bitset_set_range Fixes: b3b03e33c9f ("util/bitset: add BITSET_SET_RANGE(..)") Part-of: (cherry picked from commit 410e746198b498efdb9c37a63a0b8aad67469a4c) --- .pick_status.json | 2 +- src/util/bitset.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index 461c2f6f50a..34dbdb5235f 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -832,7 +832,7 @@ "description": "util/bitset: Fix off-by-one in __bitset_set_range", "nominated": true, "nomination_type": 1, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": "b3b03e33c9f11adb0c4d84311a651ea6016a0885" }, diff --git a/src/util/bitset.h b/src/util/bitset.h index 279ad553e79..d8ec1af67ad 100644 --- a/src/util/bitset.h +++ b/src/util/bitset.h @@ -208,7 +208,7 @@ __bitset_shl(BITSET_WORD *x, unsigned amount, unsigned n) static inline void __bitset_set_range(BITSET_WORD *r, unsigned start, unsigned end) { - const unsigned size = end - start; + const unsigned size = end - start + 1; const unsigned start_mod = start % BITSET_WORDBITS; if (start_mod + size <= BITSET_WORDBITS) {