commit:     6414c3bc394f86a5d6a5f02c934469e21bbbc923
Author:     Jason Zaman <jason <AT> perfinion <DOT> com>
AuthorDate: Wed Nov 16 04:55:49 2016 +0000
Commit:     William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Thu Nov 17 18:03:12 2016 +0000
URL:        https://gitweb.gentoo.org/proj/openrc.git/commit/?id=6414c3bc

selinux: fix SIGSEGV with invalid contexts

Fixes: https://github.com/openrc/openrc/issues/104

 src/rc/rc-selinux.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/src/rc/rc-selinux.c b/src/rc/rc-selinux.c
index a792fe2..2eb631a 100644
--- a/src/rc/rc-selinux.c
+++ b/src/rc/rc-selinux.c
@@ -334,7 +334,19 @@ void selinux_setup(char **argv)
 
        /* extract the type from the context */
        curr_con = context_new(curr_context);
-       curr_t = xstrdup(context_type_get(curr_con));
+       if (!curr_con) {
+               free(curr_context);
+               goto out;
+       }
+
+       curr_t = context_type_get(curr_con);
+       if (!curr_t) {
+               context_free(curr_con);
+               free(curr_context);
+               goto out;
+       }
+
+       curr_t = xstrdup(curr_t);
        /* dont need them anymore so free() now */
        context_free(curr_con);
        free(curr_context);

Reply via email to