summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPranith K <pranithk@gluster.com>2011-03-14 04:20:51 +0000
committerVijay Bellur <vijay@dev.gluster.com>2011-03-14 10:41:42 -0700
commitc886643f97373944030c118b7f78d0a8c06b2291 (patch)
tree3022a0529419cf7886d081110527edb6f477031c
parentac408b608130768fc9d67b836cef7c3f69f24de5 (diff)
cluster/afr: Fix wrong memory allocation
Signed-off-by: Pranith Kumar K <pranithk@gluster.com> Signed-off-by: Vijay Bellur <vijay@dev.gluster.com> BUG: 2517 (the size of allocated memory may be wrong) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=2517
-rw-r--r--xlators/cluster/afr/src/afr-self-heal-common.c2
-rw-r--r--xlators/cluster/afr/src/afr-transaction.c9
2 files changed, 6 insertions, 5 deletions
diff --git a/xlators/cluster/afr/src/afr-self-heal-common.c b/xlators/cluster/afr/src/afr-self-heal-common.c
index e716e20ef..30f0cbe09 100644
--- a/xlators/cluster/afr/src/afr-self-heal-common.c
+++ b/xlators/cluster/afr/src/afr-self-heal-common.c
@@ -118,7 +118,7 @@ afr_sh_print_pending_matrix (int32_t *pending_matrix[], xlator_t *this)
void
afr_sh_build_pending_matrix (afr_private_t *priv,
int32_t *pending_matrix[], dict_t *xattr[],
- int child_count, afr_transaction_type type)
+ int child_count, afr_transaction_type type)
{
int i, j, k;
diff --git a/xlators/cluster/afr/src/afr-transaction.c b/xlators/cluster/afr/src/afr-transaction.c
index d48d6eb72..4afb7ce6f 100644
--- a/xlators/cluster/afr/src/afr-transaction.c
+++ b/xlators/cluster/afr/src/afr-transaction.c
@@ -308,24 +308,25 @@ afr_set_piggyback_dict (afr_private_t *priv, dict_t *xattr, int32_t **pending,
int ret = 0;
int *arr = NULL;
int index = 0;
+ size_t pending_xattr_size = 3 * sizeof (int32_t);
+ /* 3 = data+metadata+entry */
index = afr_index_for_transaction_type (type);
for (i = 0; i < priv->child_count; i++) {
- arr = GF_CALLOC (3 * sizeof (int32_t), priv->child_count,
+ arr = GF_CALLOC (1, pending_xattr_size,
gf_afr_mt_char);
if (!arr) {
ret = -1;
goto out;
}
- memcpy (arr, pending[i], 3 * sizeof (int32_t));
+ memcpy (arr, pending[i], pending_xattr_size);
arr[index]++;
ret = dict_set_bin (xattr, priv->pending_key[i],
- arr, 3 * sizeof (int32_t));
- /* 3 = data+metadata+entry */
+ arr, pending_xattr_size);
if (ret < 0)
goto out;