From 05f85c40a14b014cb522e3acf692348c1edaa064 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Mon, 21 Oct 2013 17:37:31 -0700 Subject: ceph_test_librbd: fix heap overrun We are storing rbd_snap_info_t structs, not pointers to them. But we can also avoid the heap entirely. This crashed pretty reliably on arm. Signed-off-by: Sage Weil --- src/test/librbd/test_librbd.cc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/test/librbd/test_librbd.cc b/src/test/librbd/test_librbd.cc index 8052d25d6e1..67650a4edd1 100644 --- a/src/test/librbd/test_librbd.cc +++ b/src/test/librbd/test_librbd.cc @@ -435,7 +435,7 @@ int test_ls_snaps(rbd_image_t image, int num_expected, ...) rbd_snap_info_t *snaps; int num_snaps, i, j, max_size = 10; va_list ap; - snaps = (rbd_snap_info_t *) malloc(sizeof(rbd_snap_info_t *) * max_size); + rbd_snap_info_t snaps[max_size]; num_snaps = rbd_snap_list(image, snaps, &max_size); printf("num snaps is: %d\nexpected: %d\n", num_snaps, num_expected); @@ -467,7 +467,6 @@ int test_ls_snaps(rbd_image_t image, int num_expected, ...) for (i = 0; i < num_snaps; i++) { assert(snaps[i].name == NULL); } - free(snaps); return num_snaps; } -- cgit v1.2.1