From: Michael Adam Date: Thu, 20 Oct 2016 22:15:06 +0000 (+0200) Subject: vfs:glusterfs: preallocate result for glfs_realpath X-Git-Tag: samba-4.4.9~31 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=64200769c2649c44791ca3ac29442b8d42a035e6;p=thirdparty%2Fsamba.git vfs:glusterfs: preallocate result for glfs_realpath https://bugzilla.samba.org/show_bug.cgi?id=12404 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) Autobuild-User(v4-4-test): Karolin Seeger Autobuild-Date(v4-4-test): Tue Nov 8 15:35:20 CET 2016 on sn-devel-144 --- diff --git a/source3/modules/vfs_glusterfs.c b/source3/modules/vfs_glusterfs.c index 6548d7e3f36..b8ad196b5e0 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,