From patchwork Thu Jul 22 08:52:02 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Carpenter X-Patchwork-Id: 113532 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.4/8.14.3) with ESMTP id o6M8r8I6020661 for ; Thu, 22 Jul 2010 08:53:08 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758954Ab0GVIwl (ORCPT ); Thu, 22 Jul 2010 04:52:41 -0400 Received: from mail-fx0-f46.google.com ([209.85.161.46]:64532 "EHLO mail-fx0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758908Ab0GVIwg (ORCPT ); Thu, 22 Jul 2010 04:52:36 -0400 Received: by fxm14 with SMTP id 14so4102055fxm.19 for ; Thu, 22 Jul 2010 01:52:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:date:from:to:cc:subject :message-id:mime-version:content-type:content-disposition:user-agent; bh=2qCU8FdicX72ssS8uZZpHtVocAMZEOJ7BS+Xc53A8Vs=; b=UABrmEh4uFf1kWvszQlnJC4jk5wtp7lsMBwgvceNNYes5wzDvIBNF+Ih2sBoFS3C8F D66ou2rDy7D/QSoQ7mYRNHz2PgSa0aEA62KTAfhFqdKJpu7pHK1/GeHq/ixiX5LEzN8K 7oxcTz7DSnrkZ8aOYGPhQk4LsKEnVoIes3ijc= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=date:from:to:cc:subject:message-id:mime-version:content-type :content-disposition:user-agent; b=isDI78OTeoxY+ev34zEbL6Jhc+AJGx7i3rZRGtX+vdLpbT38arSaMZLd1Va0ILYaRO dgEqIqQWJ1Sn/btOj2C+Vu2yBC7Pp4ZT23GO4Ih2Dluyn7cCWg6l5X/1zBCQx0va6gPl rMLDZz8knkBEvMJZ4HKv+IdQdujUTLApQ4XKE= Received: by 10.86.63.16 with SMTP id l16mr1313053fga.25.1279788754579; Thu, 22 Jul 2010 01:52:34 -0700 (PDT) Received: from bicker ([205.177.176.130]) by mx.google.com with ESMTPS id b36sm3235352faq.35.2010.07.22.01.52.14 (version=TLSv1/SSLv3 cipher=RC4-MD5); Thu, 22 Jul 2010 01:52:33 -0700 (PDT) Date: Thu, 22 Jul 2010 10:52:02 +0200 From: Dan Carpenter To: "Luis R. Rodriguez" Cc: Nick Kossifidis , Jiri Slaby , Bob Copeland , "John W. Linville" , Bruno Randolf , linux-wireless@vger.kernel.org, ath5k-devel@venema.h4ckr.net, kernel-janitors@vger.kernel.org Subject: [patch -next] ath5k: snprintf() returns largish values Message-ID: <20100722085202.GV17585@bicker> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.18 (2008-05-17) Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Thu, 22 Jul 2010 08:53:08 +0000 (UTC) diff --git a/drivers/net/wireless/ath/ath5k/debug.c b/drivers/net/wireless/ath/ath5k/debug.c index ebb9c23..4cccc29 100644 --- a/drivers/net/wireless/ath/ath5k/debug.c +++ b/drivers/net/wireless/ath/ath5k/debug.c @@ -239,6 +239,9 @@ static ssize_t read_file_beacon(struct file *file, char __user *user_buf, "TSF\t\t0x%016llx\tTU: %08x\n", (unsigned long long)tsf, TSF_TO_TU(tsf)); + if (len > sizeof(buf)) + len = sizeof(buf); + return simple_read_from_buffer(user_buf, count, ppos, buf, len); } @@ -334,6 +337,9 @@ static ssize_t read_file_debug(struct file *file, char __user *user_buf, sc->debug.level == dbg_info[i].level ? '+' : ' ', dbg_info[i].level, dbg_info[i].desc); + if (len > sizeof(buf)) + len = sizeof(buf); + return simple_read_from_buffer(user_buf, count, ppos, buf, len); } @@ -433,6 +439,9 @@ static ssize_t read_file_antenna(struct file *file, char __user *user_buf, len += snprintf(buf+len, sizeof(buf)-len, "AR5K_PHY_ANT_SWITCH_TABLE_1\t0x%08x\n", v); + if (len > sizeof(buf)) + len = sizeof(buf); + return simple_read_from_buffer(user_buf, count, ppos, buf, len); } @@ -542,6 +551,9 @@ static ssize_t read_file_frameerrors(struct file *file, char __user *user_buf, len += snprintf(buf+len, sizeof(buf)-len, "[TX all\t%d]\n", st->tx_all_count); + if (len > sizeof(buf)) + len = sizeof(buf); + return simple_read_from_buffer(user_buf, count, ppos, buf, len); } @@ -681,6 +693,9 @@ static ssize_t read_file_ani(struct file *file, char __user *user_buf, ATH5K_ANI_CCK_TRIG_HIGH - (ATH5K_PHYERR_CNT_MAX - ath5k_hw_reg_read(sc->ah, AR5K_PHYERR_CNT2))); + if (len > sizeof(buf)) + len = sizeof(buf); + return simple_read_from_buffer(user_buf, count, ppos, buf, len); } @@ -766,6 +781,9 @@ static ssize_t read_file_queue(struct file *file, char __user *user_buf, len += snprintf(buf+len, sizeof(buf)-len, " len: %d\n", n); } + if (len > sizeof(buf)) + len = sizeof(buf); + return simple_read_from_buffer(user_buf, count, ppos, buf, len); }