[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v3 01/10] hbitmap: assert that we don't create bitmap larger than
From: |
Vladimir Sementsov-Ogievskiy |
Subject: |
[PATCH v3 01/10] hbitmap: assert that we don't create bitmap larger than INT64_MAX |
Date: |
Thu, 19 Dec 2019 13:03:39 +0300 |
We have APIs which returns signed int64_t, to be able to return error.
Therefore we can't handle bitmaps with absolute size larger than
(INT64_MAX+1). Still, keep maximum to be INT64_MAX which is a bit
safer.
Note, that bitmaps are used to represent disk images, which can't
exceed INT64_MAX anyway.
Signed-off-by: Vladimir Sementsov-Ogievskiy <address@hidden>
---
util/hbitmap.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/util/hbitmap.c b/util/hbitmap.c
index 242c6e519c..7f9b3e0cd7 100644
--- a/util/hbitmap.c
+++ b/util/hbitmap.c
@@ -716,6 +716,7 @@ HBitmap *hbitmap_alloc(uint64_t size, int granularity)
HBitmap *hb = g_new0(struct HBitmap, 1);
unsigned i;
+ assert(size <= INT64_MAX);
hb->orig_size = size;
assert(granularity >= 0 && granularity < 64);
@@ -746,6 +747,7 @@ void hbitmap_truncate(HBitmap *hb, uint64_t size)
uint64_t num_elements = size;
uint64_t old;
+ assert(size <= INT64_MAX);
hb->orig_size = size;
/* Size comes in as logical elements, adjust for granularity. */
--
2.21.0
- [PATCH v3 00/10] Further bitmaps improvements, Vladimir Sementsov-Ogievskiy, 2019/12/19
- [PATCH v3 03/10] hbitmap: unpublish hbitmap_iter_skip_words, Vladimir Sementsov-Ogievskiy, 2019/12/19
- [PATCH v3 02/10] hbitmap: move hbitmap_iter_next_word to hbitmap.c, Vladimir Sementsov-Ogievskiy, 2019/12/19
- [PATCH v3 09/10] nbd/server: use bdrv_dirty_bitmap_next_dirty_area, Vladimir Sementsov-Ogievskiy, 2019/12/19
- [PATCH v3 01/10] hbitmap: assert that we don't create bitmap larger than INT64_MAX,
Vladimir Sementsov-Ogievskiy <=
- [PATCH v3 07/10] block/dirty-bitmap: improve _next_dirty_area API, Vladimir Sementsov-Ogievskiy, 2019/12/19
- [PATCH v3 10/10] block/qcow2-bitmap: use bdrv_dirty_bitmap_next_dirty, Vladimir Sementsov-Ogievskiy, 2019/12/19
- [PATCH v3 05/10] block/dirty-bitmap: switch _next_dirty_area and _next_zero to int64_t, Vladimir Sementsov-Ogievskiy, 2019/12/19
- [PATCH v3 04/10] hbitmap: drop meta bitmaps as they are unused, Vladimir Sementsov-Ogievskiy, 2019/12/19
- [PATCH v3 08/10] nbd/server: introduce NBDExtentArray, Vladimir Sementsov-Ogievskiy, 2019/12/19
- [PATCH v3 06/10] block/dirty-bitmap: add _next_dirty API, Vladimir Sementsov-Ogievskiy, 2019/12/19