From patchwork Mon Jun 17 12:02:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?Sm9ra2UgSMOkbcOkbMOkaW5lbg==?= X-Patchwork-Id: 10998901 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CA1371395 for ; Mon, 17 Jun 2019 12:02:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B8C68288DC for ; Mon, 17 Jun 2019 12:02:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AD6A7288E2; Mon, 17 Jun 2019 12:02:43 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 67034288DD for ; Mon, 17 Jun 2019 12:02:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725826AbfFQMCn (ORCPT ); Mon, 17 Jun 2019 08:02:43 -0400 Received: from 48.23.240.77.static.louhi.net ([77.240.23.48]:35458 "EHLO kolttonen.fi" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725810AbfFQMCm (ORCPT ); Mon, 17 Jun 2019 08:02:42 -0400 Received: from 34-41-5D-CA-59-C7 (82-203-159-32.bb.dnainternet.fi [82.203.159.32]) (authenticated bits=0) by vcust561.louhi.net (8.14.7/8.14.7/0) with ESMTP id x5HC20AI020301 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO) for ; Mon, 17 Jun 2019 15:02:01 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 vcust561.louhi.net x5HC20AI020301 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kolttonen.fi; s=mail; t=1560772921; bh=iBapWBlFAC8uEhXMaDlu4Wm2rq2P36qpR8UPcFVZw/c=; h=Date:From:To:Subject:From; b=KypmUyyQc8KCLQ9L3A+xmz5cgCJOQolwLIIO9Atul4vX5PxIl+ywMdJQ/DxX5GWrO XvXCDVcKgXbd7d/C+0qkuWBAmpq52wwrObuJ8qXty3hPF15/B2RH26GX/xDJuY9x9d 2CAEL2XMEKUDo2HkdgsZ1/Kf9hhAM+wcjASUCTmW+8WWowYnVHLGQ05LDhpkXEcoLj utBROU2I9DpOc/YLd6Xc0LUNuDSs1NfQh9p9hbD6TgdqgJRtTK3S5brBqPAZiiDyEA M09Mgdces9CCu1YVNxpTX8mNmjpzYOAouF+CRFCnIbfN59/J1Z8vDQyyLWvVUzXW6i SUSA66YkiSuNQ== Date: Mon, 17 Jun 2019 15:02:39 +0300 (EEST) From: =?iso-8859-15?q?Jokke_H=E4m=E4l=E4inen?= To: selinux@vger.kernel.org Subject: [PATCH 2/2] libsepol: Replace constant with sizeof() Message-ID: User-Agent: Alpine 2.21 (LFD 202 2017-01-01) MIME-Version: 1.0 Sender: selinux-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: selinux@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Replace constant 18 with safer use of sizeof() Signed-off-by: Unto Sten --- libsepol/src/kernel_to_conf.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libsepol/src/kernel_to_conf.c b/libsepol/src/kernel_to_conf.c index 5fb4e838..930bafab 100644 --- a/libsepol/src/kernel_to_conf.c +++ b/libsepol/src/kernel_to_conf.c @@ -448,7 +448,7 @@ static int write_sids_to_conf(FILE *out, const char *const *sid_to_str, if (i < num_sids) { sid = (char *)sid_to_str[i]; } else { - snprintf(unknown, 18, "%s%u", "UNKNOWN", i); + snprintf(unknown, sizeof(unknown), "%s%u", "UNKNOWN", i); sid = strdup(unknown); if (!sid) { rc = -1; @@ -2376,7 +2376,7 @@ static int write_sid_context_rules_to_conf(FILE *out, struct policydb *pdb, cons if (i < num_sids) { sid = (char *)sid_to_str[i]; } else { - snprintf(unknown, 18, "%s%u", "UNKNOWN", i); + snprintf(unknown, sizeof(unknown), "%s%u", "UNKNOWN", i); sid = unknown; }