Fix glfs_realpath allocation in vfs_glusterfs

Signed-off-by: Anoop C S <anoopcs@redhat.com>
This commit is contained in:
Anoop C S 2016-11-04 19:40:52 +05:30
parent e077064f62
commit 58f0168507
2 changed files with 55 additions and 1 deletions

View File

@ -0,0 +1,49 @@
From 730c0a2fab4b0c494122f29355068cc2bbf0f672 Mon Sep 17 00:00:00 2001
From: Michael Adam <obnox@samba.org>
Date: Fri, 21 Oct 2016 00:15:06 +0200
Subject: [PATCH] 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 <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)
---
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 732ca51..fc40a90 100644
--- a/source3/modules/vfs_glusterfs.c
+++ b/source3/modules/vfs_glusterfs.c
@@ -1036,7 +1036,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

View File

@ -6,7 +6,7 @@
# ctdb is enabled by default, you can disable it with: --without clustering
%bcond_without clustering
%define main_release 1
%define main_release 2
%define samba_version 4.4.7
%define talloc_version 2.1.6
@ -108,6 +108,7 @@ Source200: README.dc
Source201: README.downgrade
Patch0: samba-4.4.5-fix_resolving_trusted_domain_users.patch
Patch1: samba-4.4.7-vfs_gluster_realpath.patch
BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)
@ -691,6 +692,7 @@ and use CTDB instead.
%setup -q -n samba-%{version}%{pre_release}
%patch0 -p 1 -b .samba-4.4.5-fix_resolving_trusted_domain_users.patch
%patch1 -p 1 -b .samba-4.4.7-vfs_gluster_realpath.patch
%build
%global _talloc_lib ,talloc,pytalloc,pytalloc-util
@ -1996,6 +1998,9 @@ rm -rf %{buildroot}
%endif # with_clustering_support
%changelog
* Fri Nov 04 2016 Anoop C S <anoopcs@redhat.com> - 4.4.7-2
- Fix glfs_realpath allocation in vfs_glusterfs
* Wed Oct 26 2016 Guenther Deschner <gdeschner@redhat.com> - 4.4.7-1
- Update to Samba 4.4.7