[libselinux/f18] Fix segfault from calling audit2why.finish() multiple times

Daniel J Walsh dwalsh at fedoraproject.org
Tue Oct 16 14:23:04 UTC 2012


commit f607dc2c36bd1758703ea8fe44535610ede708e1
Author: rhatdan <dwalsh at redhat.com>
Date:   Tue Oct 16 10:22:36 2012 -0400

    Fix segfault from calling audit2why.finish() multiple times

 libselinux-rhat.patch |   40 ++++++++++++++++++++++++++++++++++++++--
 libselinux.spec       |    5 ++++-
 2 files changed, 42 insertions(+), 3 deletions(-)
---
diff --git a/libselinux-rhat.patch b/libselinux-rhat.patch
index 1eed178..d5af16c 100644
--- a/libselinux-rhat.patch
+++ b/libselinux-rhat.patch
@@ -71,10 +71,29 @@ index 9f16f77..4835f2f 100644
  .SH FILES
  /etc/selinux/config
 diff --git a/libselinux/src/audit2why.c b/libselinux/src/audit2why.c
-index 02483a3..89953d7 100644
+index 02483a3..b309671 100644
 --- a/libselinux/src/audit2why.c
 +++ b/libselinux/src/audit2why.c
-@@ -206,27 +206,12 @@ static int __policy_init(const char *init_path)
+@@ -164,6 +164,9 @@ static PyObject *finish(PyObject *self __attribute__((unused)), PyObject *args)
+   
+ 	if (PyArg_ParseTuple(args,(char *)":finish")) {
+ 		int i = 0;
++		if (! avc)
++			Py_RETURN_NONE;
++
+ 		for (i = 0; i < boolcnt; i++) {
+ 			free(boollist[i]->name);
+ 			free(boollist[i]);
+@@ -177,7 +180,7 @@ static PyObject *finish(PyObject *self __attribute__((unused)), PyObject *args)
+ 		avc = NULL;
+ 		boollist = NULL;
+ 		boolcnt = 0;
+-	  
++
+ 		/* Boilerplate to return "None" */
+ 		Py_RETURN_NONE;
+ 	}
+@@ -206,27 +209,12 @@ static int __policy_init(const char *init_path)
  			return 1;
  		}
  	} else {
@@ -106,6 +125,23 @@ index 02483a3..89953d7 100644
  			PyErr_SetString( PyExc_ValueError, errormsg);
  			return 1;
  		}
+@@ -295,9 +283,16 @@ static int __policy_init(const char *init_path)
+ static PyObject *init(PyObject *self __attribute__((unused)), PyObject *args) {
+   int result;
+   char *init_path=NULL;
++  if (avc) {
++	  PyErr_SetString( PyExc_ValueError, "init called multiple times");
++	  return NULL;
++  }
++
+   if (!PyArg_ParseTuple(args,(char *)"|s:policy_init",&init_path))
+     return NULL;
++
+   result = __policy_init(init_path);
++
+   return Py_BuildValue("i", result);
+ }
+ 
 diff --git a/libselinux/src/avc.c b/libselinux/src/avc.c
 index 802a07f..6ff83a7 100644
 --- a/libselinux/src/avc.c
diff --git a/libselinux.spec b/libselinux.spec
index 0c0411b..39dc2a5 100644
--- a/libselinux.spec
+++ b/libselinux.spec
@@ -10,7 +10,7 @@
 Summary: SELinux library and simple utilities
 Name: libselinux
 Version: 2.1.12
-Release: 3%{?dist}
+Release: 4%{?dist}
 License: Public Domain
 Group: System Environment/Libraries
 Source: %{name}-%{version}.tgz
@@ -236,6 +236,9 @@ rm -rf %{buildroot}
 %{ruby_sitearch}/selinux.so
 
 %changelog
+* Mon Oct 15 2012 Dan Walsh <dwalsh at redhat.com> - 2.1.12-4
+- Fix segfault from calling audit2why.finish() multiple times
+
 * Fri Oct 12 2012 Dan Walsh <dwalsh at redhat.com> - 2.1.12-3
 - Fix up selinux man page to reference service man pages
 


More information about the scm-commits mailing list