]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph_test_librbd: fix heap overrun 754/head
authorSage Weil <sage@inktank.com>
Tue, 22 Oct 2013 16:37:08 +0000 (09:37 -0700)
committerSage Weil <sage@inktank.com>
Tue, 22 Oct 2013 16:37:08 +0000 (09:37 -0700)
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 <sage@inktank.com>
src/test/librbd/test_librbd.cc

index 8052d25d6e19a5a8e01d3d43ce3e58fa8f8ea422..5169a14e3b78ff696787ed86ca50b1029b51583e 100644 (file)
@@ -432,10 +432,9 @@ TEST(LibRBD, TestCopyPP)
 
 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 +466,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;
 }