summaryrefslogtreecommitdiffstats
path: root/api/src/glfs-handleops.c
diff options
context:
space:
mode:
authorPoornima G <pgurusid@redhat.com>2017-08-03 17:43:22 +0530
committerShyamsundar Ranganathan <srangana@redhat.com>2017-08-12 13:33:55 +0000
commitfe8fe3effb70b8c9bb0c675b867114a9b0139d0a (patch)
treee7298a5cd949136cb7d322be465f084e55ce6fc5 /api/src/glfs-handleops.c
parent814104fb21bd93d479797c4b635242ecb7fdf23f (diff)
gfapi: Duplicate the buffer sent in setxattr calls
Issue: The caller of glfs_setxattr sends a buffer to set as the value. We create a dict in which the pointer to the value is set. Underlying layers like md-cache take a ref on this dict to store the value for a longer time. But the moment setxattr is complete, the caller of glfs_setxattr can free the value memory. Solution: memcpy the setxattr value to the gluster buffer. > Reviewed-on: https://review.gluster.org/17967 > Reviewed-by: soumya k <skoduri@redhat.com> > Smoke: Gluster Build System <jenkins@build.gluster.org> > CentOS-regression: Gluster Build System <jenkins@build.gluster.org> > Reviewed-by: Jeff Darcy <jeff@pl.atyp.us> > (cherry picked from commit e11296f8e52b7e3b13d21b41d4fa34baea878edf) Change-Id: I58753fe702e8b7d0f6c4f058714c65d0ad5d7a0a BUG: 1479655 Signed-off-by: Poornima G <pgurusid@redhat.com> Reviewed-on: https://review.gluster.org/18001 Smoke: Gluster Build System <jenkins@build.gluster.org> CentOS-regression: Gluster Build System <jenkins@build.gluster.org> Reviewed-by: Shyamsundar Ranganathan <srangana@redhat.com>
Diffstat (limited to 'api/src/glfs-handleops.c')
-rw-r--r--api/src/glfs-handleops.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/api/src/glfs-handleops.c b/api/src/glfs-handleops.c
index dbffa9e26bf..4180f5cf777 100644
--- a/api/src/glfs-handleops.c
+++ b/api/src/glfs-handleops.c
@@ -481,6 +481,7 @@ pub_glfs_h_setxattrs (struct glfs *fs, struct glfs_object *object,
inode_t *inode = NULL;
loc_t loc = {0, };
dict_t *xattr = NULL;
+ void *value_cp = NULL;
/* validate in args */
if ((fs == NULL) || (object == NULL) ||
@@ -517,8 +518,13 @@ pub_glfs_h_setxattrs (struct glfs *fs, struct glfs_object *object,
goto out;
}
- xattr = dict_for_key_value (name, value, size);
+ value_cp = gf_memdup (value, size);
+ GF_CHECK_ALLOC_AND_LOG (subvol->name, value_cp, ret, "Failed to"
+ " duplicate setxattr value", out);
+
+ xattr = dict_for_key_value (name, value_cp, size, _gf_false);
if (!xattr) {
+ GF_FREE (value_cp);
ret = -1;
errno = ENOMEM;
goto out;