[packages/setools] - added format-truncation patch from git (fixes build with -Werror=format-truncation) - pass libsepo

qboosh qboosh at pld-linux.org
Wed Jul 18 18:21:54 CEST 2018


commit 682223939c185b4244db0969cc809b3d400234c2
Author: Jakub Bogusz <qboosh at pld-linux.org>
Date:   Wed Jul 18 18:23:47 2018 +0200

    - added format-truncation patch from git (fixes build with -Werror=format-truncation)
    - pass libsepol.a location (fixes build on x32 and in multilib environments)

 setools-format-truncation.patch | 98 +++++++++++++++++++++++++++++++++++++++++
 setools.spec                    |  8 ++++
 2 files changed, 106 insertions(+)
---
diff --git a/setools.spec b/setools.spec
index 6aa92a2..a9c5881 100644
--- a/setools.spec
+++ b/setools.spec
@@ -13,6 +13,9 @@ Group:		Applications/System
 #Source0Download: https://github.com/TresysTechnology/setools/releases
 Source0:	https://github.com/TresysTechnology/setools/archive/%{version}/%{name}-%{version}.tar.gz
 # Source0-md5:	54cf5c0ca2aa4ef7c6ac153981af34cd
+# https://github.com/TresysTechnology/setools/issues/174
+# https://github.com/bigon/setools/commit/e41adf01647c695b80b112b337e76021bb9f30c3.patch
+Patch0:		%{name}-format-truncation.patch
 URL:		https://github.com/TresysTechnology/setools4/wiki
 BuildRequires:	bison
 BuildRequires:	flex
@@ -161,8 +164,11 @@ Moduły graficznego interfejsu użytkownika SETools dla Pythona 3.
 
 %prep
 %setup -q
+%patch0 -p1
 
 %build
+export SEPOL=%{_libdir}/libsepol.a
+
 %if %{with python2}
 %py_build
 %endif
@@ -174,6 +180,8 @@ Moduły graficznego interfejsu użytkownika SETools dla Pythona 3.
 %install
 rm -rf $RPM_BUILD_ROOT
 
+export SEPOL=%{_libdir}/libsepol.a
+
 %if %{with python3}
 %py3_install
 %endif
diff --git a/setools-format-truncation.patch b/setools-format-truncation.patch
new file mode 100644
index 0000000..3ee3179
--- /dev/null
+++ b/setools-format-truncation.patch
@@ -0,0 +1,98 @@
+From e41adf01647c695b80b112b337e76021bb9f30c3 Mon Sep 17 00:00:00 2001
+From: Laurent Bigonville <bigon at bigon.be>
+Date: Tue, 26 Sep 2017 15:15:30 +0200
+Subject: [PATCH] Fix build failure with GCC 7 due to possible truncation of
+ snprintf output
+
+setools fails to build under GCC7 -Wformat -Werror with the following error:
+
+x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -O2 -fdebug-prefix-map=/<<PKGBUILDDIR>>=. -fstack-protector-strong -Wformat -Werror=format-security -Wno-sign-compare -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -Ilibqpol -Ilibqpol/include -I/usr/include/python3.6m -c libqpol/policy_extend.c -o build/temp.linux-amd64-3.6/libqpol/policy_extend.o -Werror -Wextra -Waggregate-return -Wfloat-equal -Wformat -Wformat=2 -Winit-self -Wmissing-format-attribute -Wmissing-include-dirs -Wnested-externs -Wold-style-definition -Wpointer-arith -Wredundant-decls -Wstrict-prototypes -Wunknown-pragmas -Wwrite-strings -Wno-missing-field-initializers -Wno-unused-parameter -Wno-cast-qual -Wno-shadow -Wno-unreachable-code -fno-exceptions
+libqpol/policy_extend.c: In function 'policy_extend':
+libqpol/policy_extend.c:161:27: error: '%04zd' directive output may be truncated writing between 4 and 10 bytes into a region of size 5 [-Werror=format-truncation=]
+    snprintf(buff, 9, "@ttr%04zd", i + 1);
+                           ^~~~~
+libqpol/policy_extend.c:161:22: note: directive argument in the range [1, 4294967295]
+    snprintf(buff, 9, "@ttr%04zd", i + 1);
+                      ^~~~~~~~~~~
+
+Increase the size of the buffer to avoid collisions
+
+Closes: https://github.com/TresysTechnology/setools/issues/174
+Signed-off-by: Laurent Bigonville <bigon at bigon.be>
+---
+ libqpol/policy_extend.c | 16 ++++++++--------
+ 1 file changed, 8 insertions(+), 8 deletions(-)
+
+diff --git a/libqpol/policy_extend.c b/libqpol/policy_extend.c
+index 742819b..739e184 100644
+--- a/libqpol/policy_extend.c
++++ b/libqpol/policy_extend.c
+@@ -110,7 +110,7 @@ static int qpol_policy_remove_bogus_aliases(qpol_policy_t * policy)
+  *  Builds data for the attributes and inserts them into the policydb.
+  *  This function modifies the policydb. Names created for attributes
+  *  are of the form @ttr<value> where value is the value of the attribute
+- *  as a four digit number (prepended with 0's as needed).
++ *  as a ten digit number (prepended with 0's as needed).
+  *  @param policy The policy from which to read the attribute map and
+  *  create the type data for the attributes. This policy will be altered
+  *  by this function.
+@@ -125,7 +125,7 @@ static int qpol_policy_build_attrs_from_map(qpol_policy_t * policy)
+ 	uint32_t bit = 0, count = 0;
+ 	ebitmap_node_t *node = NULL;
+ 	type_datum_t *tmp_type = NULL, *orig_type;
+-	char *tmp_name = NULL, buff[10];
++	char *tmp_name = NULL, buff[16];
+ 	int error = 0, retv;
+ 
+ 	INFO(policy, "%s", "Generating attributes for policy. (Step 4 of 5)");
+@@ -137,7 +137,7 @@ static int qpol_policy_build_attrs_from_map(qpol_policy_t * policy)
+ 
+ 	db = &policy->p->p;
+ 
+-	memset(&buff, 0, 10 * sizeof(char));
++	memset(&buff, 0, 16 * sizeof(char));
+ 
+ 	for (i = 0; i < db->p_types.nprim; i++) {
+ 		/* skip types */
+@@ -158,7 +158,7 @@ static int qpol_policy_build_attrs_from_map(qpol_policy_t * policy)
+ 		 * with this attribute */
+ 		/* Does not exist */
+ 		if (db->p_type_val_to_name[i] == NULL){
+-			snprintf(buff, 9, "@ttr%04zd", i + 1);
++			snprintf(buff, 15, "@ttr%010zd", i + 1);
+ 			tmp_name = strdup(buff);
+ 			if (!tmp_name) {
+ 				error = errno;
+@@ -240,7 +240,7 @@ static int qpol_policy_build_attrs_from_map(qpol_policy_t * policy)
+  *  Builds data for empty attributes and inserts them into the policydb.
+  *  This function modifies the policydb. Names created for the attributes
+  *  are of the form @ttr<value> where value is the value of the attribute
+- *  as a four digit number (prepended with 0's as needed).
++ *  as a ten digit number (prepended with 0's as needed).
+  *  @param policy The policy to which to add type data for attributes.
+  *  This policy will be altered by this function.
+  *  @return Returns 0 on success and < 0 on failure; if the call fails,
+@@ -251,7 +251,7 @@ static int qpol_policy_build_attrs_from_map(qpol_policy_t * policy)
+ static int qpol_policy_fill_attr_holes(qpol_policy_t * policy)
+ {
+ 	policydb_t *db = NULL;
+-	char *tmp_name = NULL, buff[10];
++	char *tmp_name = NULL, buff[16];
+ 	int error = 0, retv = 0;
+ 	ebitmap_t tmp_bmap = { NULL, 0 };
+ 	type_datum_t *tmp_type = NULL;
+@@ -265,12 +265,12 @@ static int qpol_policy_fill_attr_holes(qpol_policy_t * policy)
+ 
+ 	db = &policy->p->p;
+ 
+-	memset(&buff, 0, 10 * sizeof(char));
++	memset(&buff, 0, 16 * sizeof(char));
+ 
+ 	for (i = 0; i < db->p_types.nprim; i++) {
+ 		if (db->type_val_to_struct[i])
+ 			continue;
+-		snprintf(buff, 9, "@ttr%04zd", i + 1);
++		snprintf(buff, 15, "@ttr%010zd", i + 1);
+ 		tmp_name = strdup(buff);
+ 		if (!tmp_name) {
+ 			error = errno;
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/setools.git/commitdiff/682223939c185b4244db0969cc809b3d400234c2



More information about the pld-cvs-commit mailing list