c95527
From fb071c302b8cad8837bc1e57407dc3ffa14d3f99 Mon Sep 17 00:00:00 2001
c95527
From: Kamil Dudka <kdudka@redhat.com>
c95527
Date: Thu, 31 Oct 2013 19:24:35 +0100
c95527
Subject: [PATCH] libacl: fix SIGSEGV of getfacl -e on overly long group name
c95527
c95527
We simply make sure that at least one tab is used for indentation.
c95527
---
c95527
 libacl/__acl_to_any_text.c |    5 +++++
c95527
 test/root/getfacl.test     |   17 +++++++++++++++++
c95527
 2 files changed, 22 insertions(+), 0 deletions(-)
c95527
 create mode 100644 test/root/getfacl.test
c95527
c95527
diff --git a/libacl/__acl_to_any_text.c b/libacl/__acl_to_any_text.c
c95527
index a4f9c34..1d10e81 100644
c95527
--- a/libacl/__acl_to_any_text.c
c95527
+++ b/libacl/__acl_to_any_text.c
c95527
@@ -247,6 +247,11 @@ acl_entry_to_any_str(const acl_entry_t entry_d, char *text_p, ssize_t size,
c95527
 		    options & TEXT_ALL_EFFECTIVE) {
c95527
 			x = (options & TEXT_SMART_INDENT) ?
c95527
 				((text_p - orig_text_p)/8) : TABS-1;
c95527
+
c95527
+			/* use at least one tab for indentation */
c95527
+			if (x > (TABS-1))
c95527
+				x = (TABS-1);
c95527
+
c95527
 			strncpy(text_p, tabs+x, size);
c95527
 			ADVANCE(TABS-x);
c95527
 
c95527
diff --git a/test/root/getfacl.test b/test/root/getfacl.test
c95527
new file mode 100644
c95527
index 0000000..f84e25d
c95527
--- /dev/null
c95527
+++ b/test/root/getfacl.test
c95527
@@ -0,0 +1,17 @@
c95527
+Make sure that getfacl always adds at least one space between the permissions
c95527
+in an acl entry and the effective permissions comment.
c95527
+
c95527
+	$ umask 022
c95527
+	$ mkdir d
c95527
+	$ groupadd loooooooooooooooooooooooonggroup
c95527
+	$ setfacl -dm group:loooooooooooooooooooooooonggroup:rwx d
c95527
+	$ getfacl -cde d
c95527
+	> user::rwx
c95527
+	> group::r-x	#effective:r-x
c95527
+	> group:loooooooooooooooooooooooonggroup:rwx	#effective:rwx
c95527
+	> mask::rwx
c95527
+	> other::r-x
c95527
+	>
c95527
+
c95527
+	$ groupdel loooooooooooooooooooooooonggroup
c95527
+	$ rm -r d
c95527
-- 
c95527
1.7.1
c95527