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:57:53 +05:30 committed by Günther Deschner
parent 246056fcd9
commit b388f3b6b5
2 changed files with 57 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 0
%define main_release 1
%define samba_version 4.5.1
%define talloc_version 2.1.8
@ -107,6 +107,8 @@ Source6: samba.pamd
Source200: README.dc
Source201: README.downgrade
Patch0: samba-4.5.1-vfs_gluster_realpath.patch
BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)
Requires(pre): /usr/sbin/groupadd
@ -689,6 +691,8 @@ and use CTDB instead.
%prep
%setup -q -n samba-%{version}%{pre_release}
%patch0 -p 1 -b .samba-4.5.1-vfs_gluster_realpath.patch
%build
%global _talloc_lib ,talloc,pytalloc,pytalloc-util
%global _tevent_lib ,tevent,pytevent
@ -1999,6 +2003,9 @@ rm -rf %{buildroot}
%endif # with_clustering_support
%changelog
* Fri Nov 04 2016 Anoop C S <anoopcs@redhat.com> - 4.5.1-1
- Fix glfs_realpath allocation in vfs_glusterfs
* Wed Oct 26 2016 Guenther Deschner <gdeschner@redhat.com> - 4.5.1-0
- Update to Samba 4.5.1