All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kalle Valo <kvalo@qca.qualcomm.com>
To: Johannes Berg <johannes@sipsolutions.net>
Cc: Dan Carpenter <dan.carpenter@oracle.com>,
	"John W. Linville" <linville@tuxdriver.com>,
	linux-wireless@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: Re: [patch] ath6kl: use a larger buffer for debug output
Date: Mon, 21 Nov 2011 16:55:11 +0000	[thread overview]
Message-ID: <4ECA826F.8010605@qca.qualcomm.com> (raw)
In-Reply-To: <1321625461.10266.57.camel@jlt3.sipsolutions.net>

On 11/18/2011 04:11 PM, Johannes Berg wrote:
> On Fri, 2011-11-18 at 17:09 +0300, Dan Carpenter wrote:
>> This function makes the static checkers grumble.  The return value of
>> snprintf() is the number of bytes which would have been copied if
>> there was enough space.  In theory, a %u can take take 10 digits so
>> len could be larger than 16 and it would be a small information
>> leak.
>>
>> We may as well make the buffer larger as well since that is very
>> easy to do.
>>
>> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
>>
>> diff --git a/drivers/net/wireless/ath/ath6kl/debug.c b/drivers/net/wireless/ath/ath6kl/debug.c
>> index 9eff0d0..e632008 100644
>> --- a/drivers/net/wireless/ath/ath6kl/debug.c
>> +++ b/drivers/net/wireless/ath/ath6kl/debug.c
>> @@ -1551,11 +1551,12 @@ static ssize_t ath6kl_listen_int_read(struct file *file,
>>  						size_t count, loff_t *ppos)
>>  {
>>  	struct ath6kl *ar = file->private_data;
>> -	char buf[16];
>> +	char buf[32];
>>  	int len;
>>  
>>  	len = snprintf(buf, sizeof(buf), "%u %u\n", ar->listen_intvl_t,
>>  					ar->listen_intvl_b);
>> +	len = min(sizeof(buf), len);
> 
> Maybe that should be scnprintf instead then?

Yeah, I agree. And most likely debug.c has even more cases where
scnprintf() is needed.

Kalle

WARNING: multiple messages have this Message-ID (diff)
From: Kalle Valo <kvalo@qca.qualcomm.com>
To: Johannes Berg <johannes@sipsolutions.net>
Cc: Dan Carpenter <dan.carpenter@oracle.com>,
	"John W. Linville" <linville@tuxdriver.com>,
	<linux-wireless@vger.kernel.org>,
	<kernel-janitors@vger.kernel.org>
Subject: Re: [patch] ath6kl: use a larger buffer for debug output
Date: Mon, 21 Nov 2011 18:55:11 +0200	[thread overview]
Message-ID: <4ECA826F.8010605@qca.qualcomm.com> (raw)
In-Reply-To: <1321625461.10266.57.camel@jlt3.sipsolutions.net>

On 11/18/2011 04:11 PM, Johannes Berg wrote:
> On Fri, 2011-11-18 at 17:09 +0300, Dan Carpenter wrote:
>> This function makes the static checkers grumble.  The return value of
>> snprintf() is the number of bytes which would have been copied if
>> there was enough space.  In theory, a %u can take take 10 digits so
>> len could be larger than 16 and it would be a small information
>> leak.
>>
>> We may as well make the buffer larger as well since that is very
>> easy to do.
>>
>> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
>>
>> diff --git a/drivers/net/wireless/ath/ath6kl/debug.c b/drivers/net/wireless/ath/ath6kl/debug.c
>> index 9eff0d0..e632008 100644
>> --- a/drivers/net/wireless/ath/ath6kl/debug.c
>> +++ b/drivers/net/wireless/ath/ath6kl/debug.c
>> @@ -1551,11 +1551,12 @@ static ssize_t ath6kl_listen_int_read(struct file *file,
>>  						size_t count, loff_t *ppos)
>>  {
>>  	struct ath6kl *ar = file->private_data;
>> -	char buf[16];
>> +	char buf[32];
>>  	int len;
>>  
>>  	len = snprintf(buf, sizeof(buf), "%u %u\n", ar->listen_intvl_t,
>>  					ar->listen_intvl_b);
>> +	len = min(sizeof(buf), len);
> 
> Maybe that should be scnprintf instead then?

Yeah, I agree. And most likely debug.c has even more cases where
scnprintf() is needed.

Kalle

  reply	other threads:[~2011-11-21 16:55 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-18 14:09 [patch] ath6kl: use a larger buffer for debug output Dan Carpenter
2011-11-18 14:09 ` Dan Carpenter
2011-11-18 14:11 ` Johannes Berg
2011-11-18 14:11   ` Johannes Berg
2011-11-21 16:55   ` Kalle Valo [this message]
2011-11-21 16:55     ` Kalle Valo
2011-11-21 19:58     ` Dan Carpenter
2011-11-21 19:58       ` Dan Carpenter
2011-11-23  6:34   ` [patch v2] " Dan Carpenter
2011-11-23  6:34     ` Dan Carpenter
2011-11-24 12:29     ` Kalle Valo
2011-11-24 12:29       ` Kalle Valo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4ECA826F.8010605@qca.qualcomm.com \
    --to=kvalo@qca.qualcomm.com \
    --cc=dan.carpenter@oracle.com \
    --cc=johannes@sipsolutions.net \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=linville@tuxdriver.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.