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