From patchwork Thu Oct 15 21:06:05 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Williams X-Patchwork-Id: 7409911 Return-Path: X-Original-To: patchwork-linux-nvdimm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 96D36BEEA4 for ; Thu, 15 Oct 2015 21:11:50 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B78FC2069F for ; Thu, 15 Oct 2015 21:11:49 +0000 (UTC) Received: from ml01.01.org (ml01.01.org [198.145.21.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id CB3FB2069D for ; Thu, 15 Oct 2015 21:11:48 +0000 (UTC) Received: from ml01.vlan14.01.org (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id BCA17605A6; Thu, 15 Oct 2015 14:11:48 -0700 (PDT) X-Original-To: linux-nvdimm@lists.01.org Delivered-To: linux-nvdimm@lists.01.org Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by ml01.01.org (Postfix) with ESMTP id AD0E7605A6 for ; Thu, 15 Oct 2015 14:11:47 -0700 (PDT) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga103.fm.intel.com with ESMTP; 15 Oct 2015 14:11:48 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.17,687,1437462000"; d="scan'208";a="665283226" Received: from dwillia2-desk3.jf.intel.com ([10.54.39.39]) by orsmga003.jf.intel.com with ESMTP; 15 Oct 2015 14:11:47 -0700 Subject: [PATCH 04/11] ndctl: use SYSFS_ATTR_SIZE for sysfs reads From: Dan Williams To: linux-nvdimm@lists.01.org Date: Thu, 15 Oct 2015 17:06:05 -0400 Message-ID: <20151015210605.22046.56941.stgit@dwillia2-desk3.jf.intel.com> In-Reply-To: <20151015210544.22046.31483.stgit@dwillia2-desk3.jf.intel.com> References: <20151015210544.22046.31483.stgit@dwillia2-desk3.jf.intel.com> User-Agent: StGit/0.17.1-9-g687f MIME-Version: 1.0 X-BeenThere: linux-nvdimm@lists.01.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: "Linux-nvdimm developer list." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW, T_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 Static analysis points out that sysfs_read_attr() assumes @buf is at least SYSFS_ATTR_SIZE in size. Signed-off-by: Dan Williams --- lib/libndctl.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/libndctl.c b/lib/libndctl.c index 50cfbf7fe176..1149bacf67b9 100644 --- a/lib/libndctl.c +++ b/lib/libndctl.c @@ -1016,7 +1016,7 @@ NDCTL_EXPORT struct ndctl_btt *ndctl_region_get_btt_seed(struct ndctl_region *re char *path = region->region_buf; int len = region->buf_len; struct ndctl_btt *btt; - char buf[50]; + char buf[SYSFS_ATTR_SIZE]; if (snprintf(path, len, "%s/btt_seed", region->region_path) >= len) { err(ctx, "%s: buffer too small!\n", @@ -1582,7 +1582,7 @@ NDCTL_EXPORT unsigned long long ndctl_region_get_available_size( struct ndctl_ctx *ctx = ndctl_region_get_ctx(region); char *path = region->region_buf; int len = region->buf_len; - char buf[50]; + char buf[SYSFS_ATTR_SIZE]; switch (nstype) { case ND_DEVICE_NAMESPACE_PMEM: @@ -1633,7 +1633,7 @@ NDCTL_EXPORT struct ndctl_namespace *ndctl_region_get_namespace_seed( char *path = region->region_buf; struct ndctl_namespace *ndns; int len = region->buf_len; - char buf[50]; + char buf[SYSFS_ATTR_SIZE]; if (snprintf(path, len, "%s/namespace_seed", region->region_path) >= len) { err(ctx, "%s: buffer too small!\n", @@ -2944,7 +2944,7 @@ NDCTL_EXPORT struct ndctl_btt *ndctl_namespace_get_btt(struct ndctl_namespace *n char *path = ndns->ndns_buf; int len = ndns->buf_len; struct ndctl_btt *btt; - char buf[50]; + char buf[SYSFS_ATTR_SIZE]; if (snprintf(path, len, "%s/holder", ndns->ndns_path) >= len) { err(ctx, "%s: buffer too small!\n", @@ -3374,7 +3374,7 @@ static int namespace_set_size(struct ndctl_namespace *ndns, struct ndctl_ctx *ctx = ndctl_namespace_get_ctx(ndns); char *path = ndns->ndns_buf; int len = ndns->buf_len; - char buf[50]; + char buf[SYSFS_ATTR_SIZE]; if (snprintf(path, len, "%s/size", ndns->ndns_path) >= len) { err(ctx, "%s: buffer too small!\n", @@ -3613,7 +3613,7 @@ NDCTL_EXPORT struct ndctl_namespace *ndctl_btt_get_namespace(struct ndctl_btt *b struct ndctl_region *region = btt->region; char *path = region->region_buf; int len = region->buf_len; - char buf[50]; + char buf[SYSFS_ATTR_SIZE]; if (btt->ndns) return btt->ndns;