aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJason Zaman <jason@perfinion.com>2016-11-16 12:55:49 +0800
committerWilliam Hubbs <w.d.hubbs@gmail.com>2016-11-17 12:03:12 -0600
commit6414c3bc394f86a5d6a5f02c934469e21bbbc923 (patch)
treea361293e9c1c852ce8efc813fdf5681960e1e25d /src
parent4f9bd7e4db185ce6debbebb5242344d8ffadc3ae (diff)
selinux: fix SIGSEGV with invalid contexts
Fixes: https://github.com/openrc/openrc/issues/104
Diffstat (limited to 'src')
-rw-r--r--src/rc/rc-selinux.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/rc/rc-selinux.c b/src/rc/rc-selinux.c
index a792fe28..2eb631a6 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);