summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSage Weil <sage@inktank.com>2013-10-22 09:37:08 -0700
committerSage Weil <sage@inktank.com>2013-10-22 09:37:08 -0700
commitdff41cd768687c0be0ebd274c7bd6425209f9d45 (patch)
treee384d851dbbe959f308da1b1cdc73291a2c2c513
parent1f6b8b27b0e8e8374b463f995536aaeed776201f (diff)
downloadceph-dff41cd768687c0be0ebd274c7bd6425209f9d45.tar.gz
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 <sage@inktank.com>
-rw-r--r--src/test/librbd/test_librbd.cc4
1 files changed, 1 insertions, 3 deletions
diff --git a/src/test/librbd/test_librbd.cc b/src/test/librbd/test_librbd.cc
index 8052d25d6e1..5169a14e3b7 100644
--- a/src/test/librbd/test_librbd.cc
+++ b/src/test/librbd/test_librbd.cc
@@ -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;
}