From 1b0952445522af73b0e78420a9078b3653923703 Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Tue, 22 Jan 2013 15:01:12 +0100 Subject: hbitmap: add assertion on hbitmap_iter_init hbitmap_iter_init causes an out-of-bounds access when the "first" argument is or greater than or equal to the size of the bitmap. Forbid this with an assertion, and remove the failing testcase. Reported-by: Kevin Wolf Signed-off-by: Paolo Bonzini Reviewed-by: Eric Blake Reviewed-by: Laszlo Ersek Signed-off-by: Kevin Wolf --- util/hbitmap.c | 1 + 1 file changed, 1 insertion(+) (limited to 'util') diff --git a/util/hbitmap.c b/util/hbitmap.c index fb7e01e8c5..2aa487db74 100644 --- a/util/hbitmap.c +++ b/util/hbitmap.c @@ -147,6 +147,7 @@ void hbitmap_iter_init(HBitmapIter *hbi, const HBitmap *hb, uint64_t first) hbi->hb = hb; pos = first >> hb->granularity; + assert(pos < hb->size); hbi->pos = pos >> BITS_PER_LEVEL; hbi->granularity = hb->granularity; -- cgit v1.2.3