From patchwork Wed Jan 14 06:01:17 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harald Welte X-Patchwork-Id: 2276 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n0E5u7rR013738 for ; Tue, 13 Jan 2009 21:57:24 -0800 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754442AbZANGB2 (ORCPT ); Wed, 14 Jan 2009 01:01:28 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1754424AbZANGB2 (ORCPT ); Wed, 14 Jan 2009 01:01:28 -0500 Received: from ganesha.gnumonks.org ([213.95.27.120]:42381 "EHLO ganesha.gnumonks.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754193AbZANGB1 (ORCPT ); Wed, 14 Jan 2009 01:01:27 -0500 Received: from uucp by ganesha.gnumonks.org with local-bsmtp (Exim 4.63) (envelope-from ) id 1LMyog-0003AW-Sr; Wed, 14 Jan 2009 07:01:26 +0100 Received: from laforge by prithivi.gnumonks.org with local (Exim 4.69) (envelope-from ) id 1LMyoX-0002HY-Mv; Wed, 14 Jan 2009 14:01:17 +0800 Date: Wed, 14 Jan 2009 14:01:17 +0800 From: Harald Welte To: linux-acpi@vger.kernel.org Cc: lenb@kernel.org Subject: [PATCH] [ACPI] panasonic: use snprintf with PAGE_SIZE in sysfs attributes Message-ID: <20090114060117.GM4791@prithivi.gnumonks.org> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.18 (2008-05-17) Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org Instead of just sprintf() into the page-sized buffer provided by the sysfs/device_attribute API, we use snprintf with PAGE_SIZE as an additional safeguard. Signed-off-by: Martin Lucina Signed-off-by: Harald Welte --- drivers/platform/x86/panasonic-laptop.c | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/platform/x86/panasonic-laptop.c b/drivers/platform/x86/panasonic-laptop.c index 54aa8c9..1e37f9e 100644 --- a/drivers/platform/x86/panasonic-laptop.c +++ b/drivers/platform/x86/panasonic-laptop.c @@ -367,7 +367,7 @@ static ssize_t show_numbatt(struct device *dev, struct device_attribute *attr, if (!acpi_pcc_retrieve_biosdata(pcc, pcc->sinf)) return -EIO; - return sprintf(buf, "%u\n", pcc->sinf[SINF_NUM_BATTERIES]); + return snprintf(buf, PAGE_SIZE, "%u\n", pcc->sinf[SINF_NUM_BATTERIES]); } static ssize_t show_lcdtype(struct device *dev, struct device_attribute *attr, @@ -379,7 +379,7 @@ static ssize_t show_lcdtype(struct device *dev, struct device_attribute *attr, if (!acpi_pcc_retrieve_biosdata(pcc, pcc->sinf)) return -EIO; - return sprintf(buf, "%u\n", pcc->sinf[SINF_LCD_TYPE]); + return snprintf(buf, PAGE_SIZE, "%u\n", pcc->sinf[SINF_LCD_TYPE]); } static ssize_t show_mute(struct device *dev, struct device_attribute *attr, @@ -391,7 +391,7 @@ static ssize_t show_mute(struct device *dev, struct device_attribute *attr, if (!acpi_pcc_retrieve_biosdata(pcc, pcc->sinf)) return -EIO; - return sprintf(buf, "%u\n", pcc->sinf[SINF_MUTE]); + return snprintf(buf, PAGE_SIZE, "%u\n", pcc->sinf[SINF_MUTE]); } static ssize_t show_sticky(struct device *dev, struct device_attribute *attr, @@ -403,7 +403,7 @@ static ssize_t show_sticky(struct device *dev, struct device_attribute *attr, if (!acpi_pcc_retrieve_biosdata(pcc, pcc->sinf)) return -EIO; - return sprintf(buf, "%u\n", pcc->sinf[SINF_STICKY_KEY]); + return snprintf(buf, PAGE_SIZE, "%u\n", pcc->sinf[SINF_STICKY_KEY]); } static ssize_t set_sticky(struct device *dev, struct device_attribute *attr,