summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorGünther Deschner <gd@samba.org>2019-06-03 14:27:18 +0200
committerKarolin Seeger <kseeger@samba.org>2019-06-21 06:49:28 +0000
commitf830628c3aaf7e7e6243b889c67dfe661f568f24 (patch)
tree58a58c5f8c14bdafefb97a6328fde42bf434edf3 /source3
parent70e8344a0438def6fffee4c7eabdae25980cff5c (diff)
downloadsamba-f830628c3aaf7e7e6243b889c67dfe661f568f24.tar.gz
Revert "s3/vfs_glusterfs: Dynamically determine NAME_MAX"
This reverts commit 8e3a042eb9e502821b147f1bbb2d98d59f17a095. Signed-off-by: Guenther Deschner <gd@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org>
Diffstat (limited to 'source3')
-rw-r--r--source3/modules/vfs_glusterfs.c37
1 files changed, 8 insertions, 29 deletions
diff --git a/source3/modules/vfs_glusterfs.c b/source3/modules/vfs_glusterfs.c
index 5e8aad8ab5e..601be5a2da4 100644
--- a/source3/modules/vfs_glusterfs.c
+++ b/source3/modules/vfs_glusterfs.c
@@ -1446,36 +1446,20 @@ static int vfs_gluster_chflags(struct vfs_handle_struct *handle,
static int vfs_gluster_get_real_filename(struct vfs_handle_struct *handle,
const char *path, const char *name,
- TALLOC_CTX *mem_ctx, char **_found_name)
+ TALLOC_CTX *mem_ctx, char **found_name)
{
int ret;
- char *key_buf = NULL, *val_buf = NULL;
- long name_max;
- char *found_name = NULL;
+ char key_buf[NAME_MAX + 64];
+ char val_buf[NAME_MAX + 1];
- name_max = pathconf(path, _PC_NAME_MAX);
- if ((name_max + 1) < 1) {
- errno = EINVAL;
- return -1;
- }
-
- if (strlen(name) >= name_max) {
+ if (strlen(name) >= NAME_MAX) {
errno = ENAMETOOLONG;
return -1;
}
- key_buf = talloc_asprintf(mem_ctx, "glusterfs.get_real_filename:%s",
- name);
- if (key_buf == NULL) {
- errno = ENOMEM;
- return -1;
- }
+ snprintf(key_buf, NAME_MAX + 64,
+ "glusterfs.get_real_filename:%s", name);
- val_buf = talloc_zero_array(mem_ctx, char, name_max + 1);
- if (val_buf == NULL) {
- errno = ENOMEM;
- return -1;
- }
ret = glfs_getxattr(handle->data, path, key_buf, val_buf, NAME_MAX + 1);
if (ret == -1) {
if (errno == ENOATTR) {
@@ -1484,16 +1468,11 @@ static int vfs_gluster_get_real_filename(struct vfs_handle_struct *handle,
return -1;
}
- found_name = talloc_strdup(mem_ctx, val_buf);
- if (found_name == NULL) {
+ *found_name = talloc_strdup(mem_ctx, val_buf);
+ if (found_name[0] == NULL) {
errno = ENOMEM;
return -1;
}
- *_found_name = found_name;
-
- TALLOC_FREE(key_buf);
- TALLOC_FREE(val_buf);
-
return 0;
}