From: Joe Perches <joe@perches.com>
To: Dan Carpenter <error27@gmail.com>
Cc: Bruno Randolf <br1@einfach.org>,
"Luis R. Rodriguez" <lrodriguez@atheros.com>,
Nick Kossifidis <mickflemm@gmail.com>,
Jiri Slaby <jirislaby@gmail.com>,
Bob Copeland <me@bobcopeland.com>,
"John W. Linville" <linville@tuxdriver.com>,
linux-wireless@vger.kernel.org, ath5k-devel@lists.ath5k.org,
kernel-janitors <kernel-janitors@vger.kernel.org>,
LKML <linux-kernel@vger.kernel.org>
Subject: Re: [patch -next] ath5k: snprintf() returns largish values
Date: Fri, 23 Jul 2010 10:48:17 -0700 [thread overview]
Message-ID: <1279907297.24768.1678.camel@Joe-Laptop.home> (raw)
In-Reply-To: <20100723095252.GA26313@bicker>
On Fri, 2010-07-23 at 12:04 +0200, Dan Carpenter wrote:
> This is a smatch thing. I suppose someday I will fix smatch to
> evaulate the strings themselves and verify that the buffer is large
> enough. But for now it's nice to be able to automatically check that
> the buffers don't overflow.
There are also many repeated uses of snprintf in kernel sources
that could similarly be a problem.
bar += snprintf(foo + bar, ...)
bar += snprintf(foo + bar, ...)
or
foo += snprintf(foo, ...)
foo += snprintf(foo, ...)
For instance:
$ grep -P -n -A 4 -m 3 "\+=\s*snprintf" drivers/net/wireless/ath/ath5k/debug.c
210: len += snprintf(buf+len, sizeof(buf)-len,
211- "%-24s0x%08x\tintval: %d\tTIM: 0x%x\n",
212- "AR5K_BEACON", v, v & AR5K_BEACON_PERIOD,
213- (v & AR5K_BEACON_TIM) >> AR5K_BEACON_TIM_S);
214-
215: len += snprintf(buf+len, sizeof(buf)-len, "%-24s0x%08x\n",
216- "AR5K_LAST_TSTP", ath5k_hw_reg_read(sc->ah, AR5K_LAST_TSTP));
217-
218: len += snprintf(buf+len, sizeof(buf)-len, "%-24s0x%08x\n\n",
219- "AR5K_BEACON_CNT", ath5k_hw_reg_read(sc->ah, AR5K_BEACON_CNT));
220-
A conversion from snprintf to scnprintf might be appropriate
for those patterns.
next prev parent reply other threads:[~2010-07-23 17:48 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-07-22 8:52 [patch -next] ath5k: snprintf() returns largish values Dan Carpenter
2010-07-22 8:56 ` Jiri Slaby
2010-07-22 10:44 ` Dan Carpenter
2010-07-23 8:44 ` Bruno Randolf
2010-07-23 10:04 ` Dan Carpenter
2010-07-23 17:48 ` Joe Perches [this message]
2010-07-23 19:21 ` Linus Torvalds
2010-07-23 16:11 ` walter harms
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=1279907297.24768.1678.camel@Joe-Laptop.home \
--to=joe@perches.com \
--cc=ath5k-devel@lists.ath5k.org \
--cc=br1@einfach.org \
--cc=error27@gmail.com \
--cc=jirislaby@gmail.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-wireless@vger.kernel.org \
--cc=linville@tuxdriver.com \
--cc=lrodriguez@atheros.com \
--cc=me@bobcopeland.com \
--cc=mickflemm@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).