diff options
author | Martin Schwenke <martin@meltin.net> | 2015-12-01 15:32:07 +1100 |
---|---|---|
committer | Michael Adam <obnox@samba.org> | 2016-01-12 22:19:16 +0100 |
commit | 3ac2d4b59eff58f06af1eef19cef0d444f4257ca (patch) | |
tree | a9e551de7cbf7afcb072c27788aae477e287a638 | |
parent | a7ce00cc0392cbbc009e2dbe8d58258d6ba0566f (diff) | |
download | samba-3ac2d4b59eff58f06af1eef19cef0d444f4257ca.tar.gz |
ctdb-tests: Fix some incorrect memory allocations
These allocate enough memory but things get confusing if they're used
as a guide when updating the code.
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Michael Adam <obnox@samba.org>
Autobuild-User(master): Michael Adam <obnox@samba.org>
Autobuild-Date(master): Tue Jan 12 22:19:16 CET 2016 on sn-devel-144
-rw-r--r-- | ctdb/tests/src/ctdb_takeover_tests.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/ctdb/tests/src/ctdb_takeover_tests.c b/ctdb/tests/src/ctdb_takeover_tests.c index 6797de467fd..bbd004e6859 100644 --- a/ctdb/tests/src/ctdb_takeover_tests.c +++ b/ctdb/tests/src/ctdb_takeover_tests.c @@ -196,7 +196,12 @@ read_ctdb_public_ip_info(TALLOC_CTX *ctx , while (t != NULL) { n = (int) strtol(t, (char **) NULL, 10); if ((*known)[n] == NULL) { - (*known)[n] = talloc_array(ctx, struct ctdb_public_ip_list_old, CTDB_TEST_MAX_IPS); + /* Array size here has to be + * CTDB_TEST_MAX_IPS because total + * number of IPs isn't yet known */ + (*known)[n] = talloc_size(ctx, + offsetof(struct ctdb_public_ip_list_old, ips) + + CTDB_TEST_MAX_IPS * sizeof(struct ctdb_public_ip)); (*known)[n]->num = 0; } curr = (*known)[n]->num; @@ -210,7 +215,9 @@ read_ctdb_public_ip_info(TALLOC_CTX *ctx , } /* Build list of all allowed IPs */ - a = talloc_array(ctx, struct ctdb_public_ip_list_old, CTDB_TEST_MAX_IPS); + a = talloc_size(ctx, + offsetof(struct ctdb_public_ip_list_old, ips) + + numips * sizeof(struct ctdb_public_ip)); a->num = numips; for (ta = *all_ips, i=0; ta != NULL && i < numips ; ta = ta->next, i++) { a->ips[i].pnn = ta->pnn; |