From d2feb493fecf8c601fac3d9b3f993d12caf7c982 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Fri, 21 Oct 2016 00:15:06 +0200 Subject: [PATCH] vfs:glusterfs: preallocate result for glfs_realpath This makes us independent of the allocation method used inside glfs_realpath. Signed-off-by: Michael Adam Reviewed-by: Ira Cooper Autobuild-User(master): Jeremy Allison Autobuild-Date(master): Sat Oct 22 00:28:41 CEST 2016 on sn-devel-144 (cherry picked from commit 92a0a56c3852726e0812d260e043957c879aefa4) --- source3/modules/vfs_glusterfs.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/source3/modules/vfs_glusterfs.c b/source3/modules/vfs_glusterfs.c index 6548d7e..b8ad196 100644 --- a/source3/modules/vfs_glusterfs.c +++ b/source3/modules/vfs_glusterfs.c @@ -1020,7 +1020,20 @@ static int vfs_gluster_fallocate(struct vfs_handle_struct *handle, static char *vfs_gluster_realpath(struct vfs_handle_struct *handle, const char *path) { - return glfs_realpath(handle->data, path, 0); + char *result = NULL; + char *resolved_path = SMB_MALLOC_ARRAY(char, PATH_MAX+1); + + if (resolved_path == NULL) { + errno = ENOMEM; + return NULL; + } + + result = glfs_realpath(handle->data, path, resolved_path); + if (result == NULL) { + SAFE_FREE(resolved_path); + } + + return result; } static bool vfs_gluster_lock(struct vfs_handle_struct *handle, -- 2.7.4