From patchwork Sun Jan 31 10:36:38 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Iooss X-Patchwork-Id: 8173341 Return-Path: X-Original-To: patchwork-selinux@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 8FC339FC36 for ; Sun, 31 Jan 2016 10:43:49 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E6644202FE for ; Sun, 31 Jan 2016 10:43:48 +0000 (UTC) Received: from emvm-gh1-uea08.nsa.gov (emvm-gh1-uea08.nsa.gov [63.239.67.9]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 01E28202F0 for ; Sun, 31 Jan 2016 10:43:47 +0000 (UTC) X-TM-IMSS-Message-ID: <6e47af35000073e9@nsa.gov> Received: from tarius.tycho.ncsc.mil ([144.51.242.1]) by nsa.gov ([10.208.42.193]) with ESMTP (TREND IMSS SMTP Service 7.1) id 6e47af35000073e9 ; Sun, 31 Jan 2016 05:41:01 -0500 Received: from prometheus.infosec.tycho.ncsc.mil (prometheus [192.168.25.40]) by tarius.tycho.ncsc.mil (8.14.4/8.14.4) with ESMTP id u0VAg2u8020795; Sun, 31 Jan 2016 05:42:02 -0500 Received: from tarius.tycho.ncsc.mil (tarius.infosec.tycho.ncsc.mil [144.51.242.1]) by prometheus.infosec.tycho.ncsc.mil (8.15.2/8.15.2) with ESMTP id u0VAbItR201487 for ; Sun, 31 Jan 2016 05:37:18 -0500 Received: from goalie.tycho.ncsc.mil (goalie [144.51.242.250]) by tarius.tycho.ncsc.mil (8.14.4/8.14.4) with ESMTP id u0VAbIJT020323 for ; Sun, 31 Jan 2016 05:37:18 -0500 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A1BbAQCx4q1WnCIeaIFdGQEBAQEPAQEChEmIWK8kjAMBAQEBAQESAQEBAQEICwkJIYRwAQUnYlFXGYgbBAG+DoYPhX6DN4NuBZZvnDtEjXqCGAyCK2mIfQEBAQ X-IPAS-Result: A1BbAQCx4q1WnCIeaIFdGQEBAQEPAQEChEmIWK8kjAMBAQEBAQESAQEBAQEICwkJIYRwAQUnYlFXGYgbBAG+DoYPhX6DN4NuBZZvnDtEjXqCGAyCK2mIfQEBAQ X-IronPort-AV: E=Sophos;i="5.22,374,1449550800"; d="scan'208";a="5152293" Received: from emvm-gh1-uea08.nsa.gov ([10.208.42.193]) by goalie.tycho.ncsc.mil with ESMTP; 31 Jan 2016 05:37:17 -0500 X-TM-IMSS-Message-ID: <6e434c7d000073a2@nsa.gov> Received: from mx1.polytechnique.org (mx1.polytechnique.org [129.104.30.34]) by nsa.gov ([10.208.42.193]) with ESMTP (TREND IMSS SMTP Service 7.1; TLSv1/SSLv3 ADH-AES256-SHA (256/256)) id 6e434c7d000073a2 ; Sun, 31 Jan 2016 05:36:14 -0500 Received: from iosakhe.localdomain (32.206.133.77.rev.sfr.net [77.133.206.32]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) by ssl.polytechnique.org (Postfix) with ESMTPSA id D27635648D1 for ; Sun, 31 Jan 2016 11:37:13 +0100 (CET) From: Nicolas Iooss To: selinux@tycho.nsa.gov Subject: [PATCH 3/3] libsemanage: move modinfo_tmp definition before goto cleanup Date: Sun, 31 Jan 2016 11:36:38 +0100 Message-Id: <1454236598-1829-3-git-send-email-nicolas.iooss@m4x.org> X-Mailer: git-send-email 2.7.0 In-Reply-To: <1454236598-1829-1-git-send-email-nicolas.iooss@m4x.org> References: <1454236598-1829-1-git-send-email-nicolas.iooss@m4x.org> X-AV-Checked: ClamAV using ClamSMTP at svoboda.polytechnique.org (Sun Jan 31 11:37:14 2016 +0100 (CET)) X-Org-Mail: nicolas.iooss.2010@polytechnique.org X-TM-AS-MML: disable X-BeenThere: selinux@tycho.nsa.gov X-Mailman-Version: 2.1.20 Precedence: list List-Id: "Security-Enhanced Linux \(SELinux\) mailing list" List-Post: List-Help: MIME-Version: 1.0 Errors-To: selinux-bounces@tycho.nsa.gov Sender: "Selinux" X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In semanage_direct_set_module_info() and semanage_direct_list_all() functions, when modinfo_tmp variable gets initialized, a branch to "cleanup" label may have already been taken. This leads to this variable being possibly used uninitialized in these functions. This is reported by clang: direct_api.c:2491:41: error: variable 'modinfo_tmp' may be uninitialized when used here [-Werror,-Wconditional-uninitialized] ret = semanage_module_info_destroy(sh, modinfo_tmp); ^~~~~~~~~~~ direct_api.c:2334:2: note: variable 'modinfo_tmp' is declared here semanage_module_info_t *modinfo_tmp = NULL; ^ Signed-off-by: Nicolas Iooss --- libsemanage/src/direct_api.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/libsemanage/src/direct_api.c b/libsemanage/src/direct_api.c index dd621d99295e..7c84bcea629b 100644 --- a/libsemanage/src/direct_api.c +++ b/libsemanage/src/direct_api.c @@ -2136,6 +2136,7 @@ static int semanage_direct_set_module_info(semanage_handle_t *sh, char fn[PATH_MAX]; const char *path = NULL; int enabled = 0; + semanage_module_info_t *modinfo_tmp = NULL; semanage_module_key_t modkey; ret = semanage_module_key_init(sh, &modkey); @@ -2144,8 +2145,6 @@ static int semanage_direct_set_module_info(semanage_handle_t *sh, goto cleanup; } - semanage_module_info_t *modinfo_tmp = NULL; - /* check transaction */ if (!sh->is_in_transaction) { if (semanage_begin_transaction(sh) < 0) { @@ -2316,6 +2315,8 @@ static int semanage_direct_list_all(semanage_handle_t *sh, uint16_t priority = 0; + semanage_module_info_t *modinfo_tmp = NULL; + semanage_module_info_t modinfo; ret = semanage_module_info_init(sh, &modinfo); if (ret != 0) { @@ -2323,8 +2324,6 @@ static int semanage_direct_list_all(semanage_handle_t *sh, goto cleanup; } - semanage_module_info_t *modinfo_tmp = NULL; - if (sh->is_in_transaction) { toplevel = semanage_path(SEMANAGE_TMP, SEMANAGE_MODULES); } else {