Blame SOURCES/acl-2.2.51-getfacl-segv.patch

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