]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
vfs:glusterfs: preallocate result for glfs_realpath
authorMichael Adam <obnox@samba.org>
Thu, 20 Oct 2016 22:15:06 +0000 (00:15 +0200)
committerKarolin Seeger <kseeger@samba.org>
Mon, 2 Jan 2017 10:56:51 +0000 (11:56 +0100)
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 <obnox@samba.org>
Reviewed-by: Ira Cooper <ira@samba.org>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
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 <kseeger@samba.org>
Autobuild-Date(v4-4-test): Tue Nov  8 15:35:20 CET 2016 on sn-devel-144

source3/modules/vfs_glusterfs.c

index 6548d7e3f36c215197407402fab2c0d1e56e5611..b8ad196b5e085714d454670734bcaaf0a08d760c 100644 (file)
@@ -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,