aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrhatdan <dwalsh@redhat.com>2012-10-15 15:25:31 -0400
committerEric Paris <eparis@redhat.com>2013-02-05 20:14:39 -0500
commit019e6fd6d4e383ae82b65a2f5868e377dd8af571 (patch)
tree147ecaa5f3ff6f246aabf6abf331b69ad050d7f4
parent2677b72191205b329d4743d2cf0d5607091d18d0 (diff)
downloadandroid_external_selinux-019e6fd6d4e383ae82b65a2f5868e377dd8af571.tar.gz
android_external_selinux-019e6fd6d4e383ae82b65a2f5868e377dd8af571.tar.bz2
android_external_selinux-019e6fd6d4e383ae82b65a2f5868e377dd8af571.zip
libselinux: audit2why: Fix segfault if finish() called twice
If audit2why.finish is called more than once the global avc variable will be NULL, and thus dereferencing it will obviously cause problems. Thus just bail if avc is NULL and we know cleanup is done. Signed-off-by: Eric Paris <eparis@redhat.com> Acked-by: Dan Walsh <dwalsh@redhat.com>
-rw-r--r--libselinux/src/audit2why.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/libselinux/src/audit2why.c b/libselinux/src/audit2why.c
index 807bc42f..0c814aab 100644
--- a/libselinux/src/audit2why.c
+++ b/libselinux/src/audit2why.c
@@ -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;
}