summaryrefslogtreecommitdiffstats
path: root/xlators/features/trash
diff options
context:
space:
mode:
authorMichael Adam <obnox@samba.org>2015-03-31 10:30:22 +0200
committerVijay Bellur <vbellur@redhat.com>2015-03-31 23:51:33 -0700
commit5c1ce6d29ee52af9daa23c1c7a54f23ce29a687e (patch)
treecbd058854391132894fc2c84a3a441b4fa8d0897 /xlators/features/trash
parent406a9a497764d2e18b02ed8684c79fa802280405 (diff)
features/trash: fix remove_trash_path() to do what it is intended.
The intention is to set the the rem_path string pointer that is handed in from the outside. So the string has to be passed in by reference, or else the function just sets a pointer on the stack. Found by Coverity, CID 1288791 Also fixes: CID 1288791 CID 1288809 CID 1288810 CID 1288814 CID 1288815 CID 1288817 CUD 1288818 Change-Id: I6ef5eeb58b83a875cf90513291abe37dee3fc9fb BUG: 789278 Signed-off-by: Michael Adam <obnox@samba.org> Reviewed-on: http://review.gluster.org/10064 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Anoop C S <achiraya@redhat.com> Reviewed-by: Vijay Bellur <vbellur@redhat.com>
Diffstat (limited to 'xlators/features/trash')
-rw-r--r--xlators/features/trash/src/trash.c21
1 files changed, 12 insertions, 9 deletions
diff --git a/xlators/features/trash/src/trash.c b/xlators/features/trash/src/trash.c
index fb9ca9a0ee5..c1d78602c4c 100644
--- a/xlators/features/trash/src/trash.c
+++ b/xlators/features/trash/src/trash.c
@@ -118,12 +118,15 @@ copy_trash_path (const char *priv_value, gf_boolean_t internal, char *path)
* similar to orginal path.
*/
void
-remove_trash_path (const char *path, gf_boolean_t internal, char *rem_path)
+remove_trash_path (const char *path, gf_boolean_t internal, char **rem_path)
{
+ if (rem_path == NULL) {
+ return;
+ }
- rem_path = strchr (path + 1, '/');
+ *rem_path = strchr (path + 1, '/');
if (internal)
- rem_path = strchr (path + 1, '/');
+ *rem_path = strchr (path + 1, '/');
}
/**
@@ -643,7 +646,7 @@ trash_unlink_mkdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
goto out;
}
strcpy (real_path, priv->brick_path);
- remove_trash_path (tmp_path, (frame->root->pid < 0), tmp_stat);
+ remove_trash_path (tmp_path, (frame->root->pid < 0), &tmp_stat);
if (tmp_stat)
strcat (real_path, tmp_stat);
STACK_WIND_COOKIE (frame, trash_unlink_mkdir_cbk, tmp_path,
@@ -713,7 +716,7 @@ trash_unlink_mkdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
}
strcpy (real_path, priv->brick_path);
- remove_trash_path (tmp_path, (frame->root->pid < 0), tmp_stat);
+ remove_trash_path (tmp_path, (frame->root->pid < 0), &tmp_stat);
if (tmp_stat)
strcat (real_path, tmp_stat);
@@ -784,7 +787,7 @@ trash_unlink_rename_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
goto out;
}
strcpy (real_path, priv->brick_path);
- remove_trash_path (tmp_str, (frame->root->pid < 0), tmp_stat);
+ remove_trash_path (tmp_str, (frame->root->pid < 0), &tmp_stat);
if (tmp_stat)
strcat (real_path, tmp_stat);
/* create the directory with proper permissions */
@@ -1230,7 +1233,7 @@ trash_truncate_create_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
goto out;
}
strcpy (real_path, priv->brick_path);
- remove_trash_path (tmp_path, (frame->root->pid < 0), tmp_stat);
+ remove_trash_path (tmp_path, (frame->root->pid < 0), &tmp_stat);
if (tmp_stat)
strcat (real_path, tmp_stat);
/* create the directory with proper permissions */
@@ -1352,7 +1355,7 @@ trash_truncate_mkdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
goto out;
}
strcpy (real_path, priv->brick_path);
- remove_trash_path (tmp_path, (frame->root->pid < 0), tmp_stat);
+ remove_trash_path (tmp_path, (frame->root->pid < 0), &tmp_stat);
if (tmp_stat)
strcat (real_path, tmp_stat);
STACK_WIND_COOKIE (frame, trash_truncate_mkdir_cbk,
@@ -1422,7 +1425,7 @@ trash_truncate_mkdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
}
strcpy (real_path, priv->brick_path);
- remove_trash_path (tmp_path, (frame->root->pid < 0), tmp_stat);
+ remove_trash_path (tmp_path, (frame->root->pid < 0), &tmp_stat);
if (tmp_stat)
strcat (real_path, tmp_stat);