diff options
author | Raghavendra G <raghavendra@gluster.com> | 2009-11-18 01:17:25 +0000 |
---|---|---|
committer | Anand V. Avati <avati@dev.gluster.com> | 2009-11-18 21:14:37 -0800 |
commit | 134d85015b0251ddc079678e1e0997cb41d0516b (patch) | |
tree | be6d9d95086edfd2a7d7c0005137b97304cdb315 /libglusterfsclient | |
parent | 1f1d1569f4bcd8acbfb80e0bdd11b752cdead637 (diff) |
libglusterfsclient: getxattr should return the length of the xattr when size is zero
Signed-off-by: Raghavendra G <raghavendra@gluster.com>
Signed-off-by: Anand V. Avati <avati@dev.gluster.com>
BUG: 369 (Samba does not work with booster.)
URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=369
Diffstat (limited to 'libglusterfsclient')
-rwxr-xr-x | libglusterfsclient/src/libglusterfsclient.c | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/libglusterfsclient/src/libglusterfsclient.c b/libglusterfsclient/src/libglusterfsclient.c index fb48fc300da..c241f1fc3f4 100755 --- a/libglusterfsclient/src/libglusterfsclient.c +++ b/libglusterfsclient/src/libglusterfsclient.c @@ -2613,11 +2613,6 @@ __glusterfs_glh_getxattr (glusterfs_handle_t handle, const char *path, goto out; } - if (size == 0) { - op_ret = 0; - goto out; - } - if (size < 0) { errno = EINVAL; gf_log (LIBGF_XL_NAME, GF_LOG_ERROR, "Invalid argument: size is" @@ -2681,10 +2676,13 @@ do_getx: /* Don't return the value for '\0' */ op_ret = value_data->len; - - copy_len = size < value_data->len ? - size : value_data->len; - memcpy (value, value_data->data, copy_len); + + if ((size > 0) && (value != NULL)) { + copy_len = size < value_data->len ? + size : value_data->len; + memcpy (value, value_data->data, copy_len); + op_ret = copy_len; + } } else { errno = ENODATA; op_ret = -1; @@ -2738,7 +2736,12 @@ glusterfs_getxattr (const char *path, const char *name, void *value, GF_VALIDATE_OR_GOTO (LIBGF_XL_NAME, path, out); GF_VALIDATE_OR_GOTO (LIBGF_XL_NAME, name, out); - GF_VALIDATE_OR_GOTO (LIBGF_XL_NAME, value, out); + + if ((size > 0) && (value == NULL)) { + errno = EINVAL; + gf_log (LIBGF_XL_NAME, GF_LOG_ERROR, "Invalid argument value"); + goto out; + } gf_log (LIBGF_XL_NAME, GF_LOG_DEBUG, "path %s, name %s, size %lu", path, name, (long unsigned)size); @@ -2766,7 +2769,12 @@ glusterfs_lgetxattr (const char *path, const char *name, void *value, GF_VALIDATE_OR_GOTO (LIBGF_XL_NAME, path, out); GF_VALIDATE_OR_GOTO (LIBGF_XL_NAME, name, out); - GF_VALIDATE_OR_GOTO (LIBGF_XL_NAME, value, out); + + if ((size > 0) && (value == NULL)) { + errno = EINVAL; + gf_log (LIBGF_XL_NAME, GF_LOG_ERROR, "Invalid argument value"); + goto out; + } gf_log (LIBGF_XL_NAME, GF_LOG_DEBUG, "path %s, name %s, size %lu", path, name, (long unsigned)size); |