diff options
author | Paolo Bonzini <pbonzini@redhat.com> | 2013-01-22 15:01:12 +0100 |
---|---|---|
committer | Kevin Wolf <kwolf@redhat.com> | 2013-01-25 18:18:35 +0100 |
commit | 1b0952445522af73b0e78420a9078b3653923703 (patch) | |
tree | b736c93c1884f518c567d4ff3bd7dc9199ec4948 /tests | |
parent | 88ff0e48eedd679a9dc1122676d8aa29f8d07571 (diff) | |
download | qemu-1b0952445522af73b0e78420a9078b3653923703.zip qemu-1b0952445522af73b0e78420a9078b3653923703.tar.gz qemu-1b0952445522af73b0e78420a9078b3653923703.tar.bz2 |
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 <kwolf@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test-hbitmap.c | 13 |
1 files changed, 3 insertions, 10 deletions
diff --git a/tests/test-hbitmap.c b/tests/test-hbitmap.c index fcc6a00..8c902f2 100644 --- a/tests/test-hbitmap.c +++ b/tests/test-hbitmap.c @@ -86,7 +86,9 @@ static void hbitmap_test_init(TestHBitmapData *data, data->bits = g_new0(unsigned long, n); data->size = size; data->granularity = granularity; - hbitmap_test_check(data, 0); + if (size) { + hbitmap_test_check(data, 0); + } } static void hbitmap_test_teardown(TestHBitmapData *data, @@ -198,14 +200,6 @@ static void test_hbitmap_iter_partial(TestHBitmapData *data, hbitmap_test_check(data, L3 / 2); } -static void test_hbitmap_iter_past(TestHBitmapData *data, - const void *unused) -{ - hbitmap_test_init(data, L3, 0); - hbitmap_test_set(data, 0, L3); - hbitmap_test_check(data, L3); -} - static void test_hbitmap_set_all(TestHBitmapData *data, const void *unused) { @@ -388,7 +382,6 @@ int main(int argc, char **argv) hbitmap_test_add("/hbitmap/size/0", test_hbitmap_zero); hbitmap_test_add("/hbitmap/size/unaligned", test_hbitmap_unaligned); hbitmap_test_add("/hbitmap/iter/empty", test_hbitmap_iter_empty); - hbitmap_test_add("/hbitmap/iter/past", test_hbitmap_iter_past); hbitmap_test_add("/hbitmap/iter/partial", test_hbitmap_iter_partial); hbitmap_test_add("/hbitmap/iter/granularity", test_hbitmap_iter_granularity); hbitmap_test_add("/hbitmap/get/all", test_hbitmap_get_all); |