From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 590E21395E2 for ; Wed, 30 Nov 2016 22:49:10 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id BC45FE0C9E; Wed, 30 Nov 2016 22:49:07 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id A2317E0C9E for ; Wed, 30 Nov 2016 22:49:07 +0000 (UTC) Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 85E06341301 for ; Wed, 30 Nov 2016 22:49:04 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 5912224A4 for ; Wed, 30 Nov 2016 22:49:02 +0000 (UTC) From: "William Hubbs" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "William Hubbs" Message-ID: <1479405792.6414c3bc394f86a5d6a5f02c934469e21bbbc923.williamh@OpenRC> Subject: [gentoo-commits] proj/openrc:master commit in: src/rc/ X-VCS-Repository: proj/openrc X-VCS-Files: src/rc/rc-selinux.c X-VCS-Directories: src/rc/ X-VCS-Committer: williamh X-VCS-Committer-Name: William Hubbs X-VCS-Revision: 6414c3bc394f86a5d6a5f02c934469e21bbbc923 X-VCS-Branch: master Date: Wed, 30 Nov 2016 22:49:02 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: 246aa874-d3fa-4081-8fb0-07f40c6ddac6 X-Archives-Hash: 167f37d4094ba448989bdc0c72b51f6d commit: 6414c3bc394f86a5d6a5f02c934469e21bbbc923 Author: Jason Zaman perfinion com> AuthorDate: Wed Nov 16 04:55:49 2016 +0000 Commit: William Hubbs gentoo 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);