From patchwork Fri Sep 23 18:02:53 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Roberts, William C" X-Patchwork-Id: 9348561 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 235816077A for ; Fri, 23 Sep 2016 18:04:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1910B2AD5F for ; Fri, 23 Sep 2016 18:04:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0DE7E2AD61; Fri, 23 Sep 2016 18:04:10 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from emsm-gh1-uea11.nsa.gov (smtp.nsa.gov [8.44.101.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 6525C2AD5F for ; Fri, 23 Sep 2016 18:04:08 +0000 (UTC) X-IronPort-AV: E=Sophos;i="5.30,382,1470700800"; d="scan'208";a="19514284" IronPort-PHdr: =?us-ascii?q?9a23=3A2rUIuBOF0ZrPZ4yI1pkl6mtUPXoX/o7sNwtQ0KIM?= =?us-ascii?q?zox0KPr5rarrMEGX3/hxlliBBdydsKMezbKJ+Pm5ByQp2tWoiDg6aptCVhsI24?= =?us-ascii?q?09vjcLJ4q7M3D9N+PgdCcgHc5PBxdP9nC/NlVJSo6lPwWB6kO74TNaIBjjLw09?= =?us-ascii?q?fr2zQd+IyZzonLnrpdX6WEZhvHKFe7R8LRG7/036l/I9ps9cEJs30QbDuXBSeu?= =?us-ascii?q?5blitCLFOXmAvgtI/rpMYwuxlKv7od0+IIEeCjJ+VrBYBfWS8rN2Ez+d3DqQjI?= =?us-ascii?q?TQzJ4GAVFGoRjF4AGATexA3rVZf29C3hv6xy3zfJE9fxSOUrWDCm7q5uDhSuki?= =?us-ascii?q?ANOiQl60nWjNB9iORQpxfy9FRE34fIbdTNZ7JFdaTHcIZfHDJM?= X-IPAS-Result: =?us-ascii?q?A2FZBQDMbeVX/wHyM5BdHAEBBAEBCgEBFwEBBAEBCgEBgxA?= =?us-ascii?q?BAQEBAR6BU6Y0lEEjh2tMAQEBAQEBAQECAQJbJ4IyBAMTBYIYAiQTFCAOAwkCF?= =?us-ascii?q?wghCAgDAS0VGAcLBRgEiCq9MAEkiDuGZhEBhXoFjyuKS49oAol7hWwCSJAfVIU?= =?us-ascii?q?lUgGFM3iBJwEBAQ?= Received: from unknown (HELO tarius.tycho.ncsc.mil) ([144.51.242.1]) by emsm-gh1-uea11.nsa.gov with ESMTP; 23 Sep 2016 18:04:05 +0000 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 u8NI34Vd020954; Fri, 23 Sep 2016 14:03:28 -0400 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 u8NI3275198232 for ; Fri, 23 Sep 2016 14:03:02 -0400 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 u8NI2xxj020923; Fri, 23 Sep 2016 14:03:02 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A1A9BAACbeVX/yNjr8ZdGgEBAQECAQEBAQgBAQEBgzsBAQEBAR6BU7ZshBMUhgqBZkwBAgEBAQEBAl6FNlIwgQ8SiEu9ITGIO4xyBY8rikuPaAKPZwJIkB9UhSUeNAGHUgEBAQ X-IPAS-Result: A1A9BAACbeVX/yNjr8ZdGgEBAQECAQEBAQgBAQEBgzsBAQEBAR6BU7ZshBMUhgqBZkwBAgEBAQEBAl6FNlIwgQ8SiEu9ITGIO4xyBY8rikuPaAKPZwJIkB9UhSUeNAGHUgEBAQ X-IronPort-AV: E=Sophos;i="5.30,382,1470715200"; d="scan'208";a="5725806" Received: from emsm-gh1-uea11.corp.nsa.gov (HELO emsm-gh1-uea11.nsa.gov) ([10.208.41.37]) by goalie.tycho.ncsc.mil with ESMTP; 23 Sep 2016 14:03:01 -0400 IronPort-PHdr: =?us-ascii?q?9a23=3AOCMayB2hYEi3OklcsmDT+DRfVm0co7zxezQtwd8Z?= =?us-ascii?q?segQI/ad9pjvdHbS+e9qxAeQG96KsbQc1KGP6v6ocFdDyK7JiGoFfp1IWk1Nou?= =?us-ascii?q?QttCtkPvS4D1bmJuXhdS0wEZcKflZk+3amLRodQ56mNBXsq3G/pQQfBg/4fVIs?= =?us-ascii?q?YL+kQMiK0I/ujr760qaQSj0AvCC6b7J2IUf+hiTqne5Sv7FfLL0swADCuHpCdr?= =?us-ascii?q?ce72ppIVWOg0S0vZ/or9ZLuh5dsPM59sNGTb6yP+FhFeQZX3waNDUu6cnqswTT?= =?us-ascii?q?ZRee7XsbFGMNm1xHBBaBpAr2Rb/toyD6sax7wyDcMsroHp4uXjH38KZvTB7hjW?= =?us-ascii?q?EMcSQ++mzNltdYjaRHrRbnrBt6kN2cW52cKPcrJvCVRtgdX2cUG58JDyE=3D?= X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: =?us-ascii?q?A0HABADMbeVX/yNjr8ZdGwEBAQMBAQEJA?= =?us-ascii?q?QEBFwEBBAEBCgEBgxABAQEBAR6BU6Y0kDiEExSGCoFmTAEBAQEBAQEBAgECWye?= =?us-ascii?q?CMgQBFQEEgj5SMIEPEohLvSQMJYg7jHIFjyuKS49oAo9nAkiQH1SFJR40AYYSg?= =?us-ascii?q?UABAQE?= X-IPAS-Result: =?us-ascii?q?A0HABADMbeVX/yNjr8ZdGwEBAQMBAQEJAQEBFwEBBAEBCgE?= =?us-ascii?q?BgxABAQEBAR6BU6Y0kDiEExSGCoFmTAEBAQEBAQEBAgECWyeCMgQBFQEEgj5SM?= =?us-ascii?q?IEPEohLvSQMJYg7jHIFjyuKS49oAo9nAkiQH1SFJR40AYYSgUABAQE?= X-IronPort-AV: E=Sophos;i="5.30,382,1470700800"; d="scan'208";a="19514236" Received: from fmsmga002-icc.fm.intel.com ([198.175.99.35]) by emsm-gh1-uea11.nsa.gov with ESMTP; 23 Sep 2016 18:03:00 +0000 Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga002-icc.fm.intel.com with ESMTP; 23 Sep 2016 11:03:00 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.30,382,1470726000"; d="scan'208";a="883150129" Received: from pbridd-mobl.amr.corp.intel.com (HELO wcrobert-MOBL1.amr.corp.intel.com) ([10.252.200.18]) by orsmga003.jf.intel.com with ESMTP; 23 Sep 2016 11:02:59 -0700 From: william.c.roberts@intel.com To: selinux@tycho.nsa.gov, sds@tycho.nsa.gov Subject: [PATCH] libselinux: drop usage of _D_ALLOC_NAMLEN Date: Fri, 23 Sep 2016 11:02:53 -0700 Message-Id: <1474653773-10575-1-git-send-email-william.c.roberts@intel.com> X-Mailer: git-send-email 1.9.1 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-Virus-Scanned: ClamAV using ClamSMTP From: William Roberts _D_ALLOC_NAMLEN is not very portable. Currently, the code mallocs based on _D_ALLOC_NAMLEN() and then strcpy's dirent d_name into the buffer. Instead, just use strdup. Change-Id: I5c8ca47da2c593ea2726caba5781f5e9d9d910ae Signed-off-by: William Roberts --- libselinux/src/booleans.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/libselinux/src/booleans.c b/libselinux/src/booleans.c index 4b39a28..c438af1 100644 --- a/libselinux/src/booleans.c +++ b/libselinux/src/booleans.c @@ -63,12 +63,11 @@ int security_get_boolean_names(char ***names, int *len) } for (i = 0; i < *len; i++) { - n[i] = (char *)malloc(_D_ALLOC_NAMLEN(namelist[i])); + n[i] = strdup(namelist[i]->d_name); if (!n[i]) { rc = -1; goto bad_freen; } - strcpy(n[i], namelist[i]->d_name); } rc = 0; *names = n;