From patchwork Mon Nov 23 13:52:41 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Haines X-Patchwork-Id: 7682281 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 44AFB9F1D3 for ; Mon, 23 Nov 2015 13:56:32 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 409ED206FD for ; Mon, 23 Nov 2015 13:56:27 +0000 (UTC) Received: from emvm-gh1-uea09.nsa.gov (emvm-gh1-uea09.nsa.gov [63.239.67.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id DC80B206B6 for ; Mon, 23 Nov 2015 13:56:25 +0000 (UTC) X-TM-IMSS-Message-ID: <5078b2930002f708@nsa.gov> Received: from tarius.tycho.ncsc.mil ([144.51.242.1]) by nsa.gov ([63.239.67.10]) with ESMTP (TREND IMSS SMTP Service 7.1) id 5078b2930002f708 ; Mon, 23 Nov 2015 08:55:30 -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 tANDrAHj027836; Mon, 23 Nov 2015 08:53:23 -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 tANDr7bO008735 for ; Mon, 23 Nov 2015 08:53:07 -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 tANDr5jI027825 for ; Mon, 23 Nov 2015 08:53:06 -0500 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A1B7AABYGVNWnN8AFEFeGQQPAQEChE29BIQDCheFeIFBTAEBAQEBARIBAQEBAQgLCQkhhGYqGQEBNwGBUIgYAQMSBK0jhVQBBYEEii8GhESJYYFVf4IUDEGBMZZVnBiNZIItOiOBXXKDYYFKAQEB X-IPAS-Result: A1B7AABYGVNWnN8AFEFeGQQPAQEChE29BIQDCheFeIFBTAEBAQEBARIBAQEBAQgLCQkhhGYqGQEBNwGBUIgYAQMSBK0jhVQBBYEEii8GhESJYYFVf4IUDEGBMZZVnBiNZIItOiOBXXKDYYFKAQEB X-IronPort-AV: E=Sophos;i="5.20,337,1444708800"; d="scan'208";a="4957236" Received: from emvm-gh1-uea09.nsa.gov ([63.239.67.10]) by goalie.tycho.ncsc.mil with ESMTP; 23 Nov 2015 08:52:50 -0500 X-TM-IMSS-Message-ID: <50773b900002f6a3@nsa.gov> Received: from rgout0502.bt.lon5.cpcloud.co.uk (rgout0502.bt.lon5.cpcloud.co.uk [65.20.0.223]) by nsa.gov ([63.239.67.10]) with ESMTP (TREND IMSS SMTP Service 7.1) id 50773b900002f6a3 ; Mon, 23 Nov 2015 08:53:54 -0500 X-OWM-Source-IP: 86.134.53.217 (GB) X-OWM-Env-Sender: richard_c_haines@btinternet.com X-CTCH-RefID: str=0001.0A090205.56531A30.00AC, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0 X-Junkmail-Premium-Raw: score=27/50, refid=2.7.2:2015.11.23.124815:17:27.888, ip=86.134.53.217, rules=__HAS_FROM, __PHISH_FROM2, __FRAUD_WEBMAIL_FROM, __TO_MALFORMED_2, __TO_NO_NAME, __SUBJ_ALPHA_END, __HAS_MSGID, __SANE_MSGID, __HAS_X_MAILER, __ANY_URI, __FRAUD_BODY_WEBMAIL, __URI_NO_WWW, __URI_NO_PATH, BODY_SIZE_1100_1199, BODYTEXTP_SIZE_3000_LESS, __MIME_TEXT_ONLY, RDNS_GENERIC_POOLED, __URI_NS, SXL_IP_DYNAMIC[217.53.134.86.fur], HTML_00_01, HTML_00_10, BODY_SIZE_5000_LESS, RDNS_SUSP_GENERIC, __PHISH_FROM, __PHISH_SPEAR_STRUCTURE_1, BODY_SIZE_2000_LESS, RDNS_SUSP, __FRAUD_WEBMAIL, BODY_SIZE_7000_LESS, NO_URI_HTTPS X-CTCH-Spam: Unknown Received: from localhost.localdomain (86.134.53.217) by rgout05.bt.lon5.cpcloud.co.uk (8.6.122.06) (authenticated as richard_c_haines@btinternet.com) id 5651ED3800179415; Mon, 23 Nov 2015 13:52:37 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=btinternet.com; s=btcpcloud; t=1448286759; bh=p8/kDuzkFUgsIHflI18YQ81IjOGLE3UXMiC9NkJ6l3o=; h=From:To:Cc:Subject:Date:Message-Id:X-Mailer; b=YE97OguDpAd2Tw9YpVnAP5MtpFSbY4BmTtAByVyg3QP7sH7Foa/KAl5Nm8YqzJVtqjP7K/OFm0lUuqEYUq7xU3RuY/heGQ82uZU896Zy/hAkiqrQsoFnDXG26xWewiongNRUyGTveIp2BcdJ7FKpRKA03yXCzpIcguI5kdc5/8k= From: Richard Haines To: selinux@tycho.nsa.gov Subject: [PATCH] libselinux: Correct line count for property and service contexts files Date: Mon, 23 Nov 2015 13:52:41 +0000 Message-Id: <1448286761-4903-1-git-send-email-richard_c_haines@btinternet.com> X-Mailer: git-send-email 2.5.0 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.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=ham 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 When a line number is displayed for context errors they are x2 the correct value, so reset line count for each pass. Signed-off-by: Richard Haines Acked-by: Jeff Vander Stoep --- libselinux/src/label_android_property.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libselinux/src/label_android_property.c b/libselinux/src/label_android_property.c index 712eecb..fea1f8f 100644 --- a/libselinux/src/label_android_property.c +++ b/libselinux/src/label_android_property.c @@ -132,7 +132,7 @@ static int init(struct selabel_handle *rec, const struct selinux_opt *opts, const char *path = NULL; FILE *fp; char line_buf[BUFSIZ]; - unsigned int lineno = 0, maxnspec, pass; + unsigned int lineno, maxnspec, pass; int status = -1; struct stat sb; @@ -166,6 +166,7 @@ static int init(struct selabel_handle *rec, const struct selinux_opt *opts, maxnspec = UINT_MAX / sizeof(spec_t); for (pass = 0; pass < 2; pass++) { data->nspec = 0; + lineno = 0; while (fgets(line_buf, sizeof(line_buf) - 1, fp) && data->nspec < maxnspec) {