summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJiffin Tony Thottan <jthottan@redhat.com>2015-04-13 15:23:51 +0530
committerVijay Bellur <vbellur@redhat.com>2015-04-23 07:07:08 -0700
commit14d75b9ded15c36ddd9b470f8ed2739bc94454fd (patch)
tree04490784c7d470c001aef04ca775dae4549f1f58
parent8611fe7b30f86ddde5d5acfde45a6ec424186e02 (diff)
features/trash : fixing trash dir option
Backport of http://review.gluster.org/#/c/10215/ Previously, problem was caused due to buffer overflow of variable used in the code. This patch fix the same. Change-Id: I3df5e06044470022f9475d93d33447db35384da2 BUG: 1214563 Signed-off-by: Jiffin Tony Thottan <jthottan@redhat.com> Reviewed-on: http://review.gluster.org/10345 Tested-by: NetBSD Build System Reviewed-by: Emmanuel Dreyfus <manu@netbsd.org> Tested-by: Emmanuel Dreyfus <manu@netbsd.org> Reviewed-by: Vijay Bellur <vbellur@redhat.com>
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-op-sm.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.c b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
index 5bfdb0bb43e..20aab8dfe27 100644
--- a/xlators/mgmt/glusterd/src/glusterd-op-sm.c
+++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
@@ -662,6 +662,7 @@ glusterd_op_stage_set_volume (dict_t *dict, char **op_errstr)
char *val_dup = NULL;
char str[100] = {0, };
char *trash_path = NULL;
+ int trash_path_len = 0;
int count = 0;
int dict_count = 0;
char errstr[2048] = {0, };
@@ -983,9 +984,14 @@ glusterd_op_stage_set_volume (dict_t *dict, char **op_errstr)
brick_list) {
/* Check for local brick */
if (!gf_uuid_compare (brickinfo->uuid, MY_UUID)) {
- trash_path = gf_strdup (brickinfo->path);
- strcat(trash_path, "/");
- strcat(trash_path, value);
+ trash_path_len = strlen (value) +
+ strlen (brickinfo->path) + 2;
+ trash_path = GF_CALLOC (1,
+ trash_path_len,
+ gf_common_mt_char);
+ snprintf (trash_path, trash_path_len,
+ "%s/%s", brickinfo->path,
+ value);
/* Checks whether a directory with
given option exists or not */
@@ -1016,6 +1022,11 @@ glusterd_op_stage_set_volume (dict_t *dict, char **op_errstr)
goto out;
}
}
+ if (trash_path) {
+ GF_FREE (trash_path);
+ trash_path = NULL;
+ trash_path_len = 0;
+ }
}
} else if (!strcmp(key, "features.trash-dir") && !trash_enabled) {
snprintf (errstr, sizeof (errstr),