From: Joe Perches <joe@perches.com>
To: Chen Gang <gang.chen@asianux.com>
Cc: stas.yakovlev@gmail.com, linville@tuxdriver.com,
linux-wireless@vger.kernel.org, netdev@vger.kernel.org
Subject: Re: [PATCH] drivers/net/wireless/ipw2x00: use strlcpy instead of strncpy
Date: Sun, 06 Jan 2013 19:19:06 -0800 [thread overview]
Message-ID: <1357528746.4940.31.camel@joe-AO722> (raw)
In-Reply-To: <50EA37CE.1090901@asianux.com>
On Mon, 2013-01-07 at 10:49 +0800, Chen Gang wrote:
> but I think the original author intended to use escaped instead of ssid
> DECLARE_SSID_BUF(ssid) (line 5525, 5737)
> use ssid to print debug information directly
> (such as: line 5530..5535, 5545..5549, 5745..5749, ...)
> when need print additional information, use escaped
> (line 5559..5569, 5773..5782, 5791..5799)
>
> so, I still suggest:
> only fix the bug (use strlcpy instead of strncpy)
> and not touch original features which orignal author intended using.
More likely John Linville just missed the conversions.
4+ years ago.
commit 9387b7caf3049168fc97a8a9111af8fe2143af18
Author: John W. Linville <linville@tuxdriver.com>
Date: Tue Sep 30 20:59:05 2008 -0400
wireless: use individual buffers for printing ssid values
Also change escape_ssid to print_ssid to match print_mac semantics.
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Maybe these days this should be another vsprintf %p extension
like %pM when the DECLARE_MAC_BUF/print_mac uses were converted.
(or maybe extend %ph for ssids with %*phs, length, array)
But if and until then, I suggest this instead:
drivers/net/wireless/ipw2x00/ipw2200.c | 38 ++++++++++++++--------------------
1 file changed, 15 insertions(+), 23 deletions(-)
diff --git a/drivers/net/wireless/ipw2x00/ipw2200.c b/drivers/net/wireless/ipw2x00/ipw2200.c
index 844f201..3dc6a92 100644
--- a/drivers/net/wireless/ipw2x00/ipw2200.c
+++ b/drivers/net/wireless/ipw2x00/ipw2200.c
@@ -5556,15 +5556,12 @@ static int ipw_find_adhoc_network(struct ipw_priv *priv,
((network->ssid_len != priv->essid_len) ||
memcmp(network->ssid, priv->essid,
min(network->ssid_len, priv->essid_len)))) {
- char escaped[IW_ESSID_MAX_SIZE * 2 + 1];
+ DECLARE_SSID_BUF(escaped);
- strncpy(escaped,
- print_ssid(ssid, network->ssid,
- network->ssid_len),
- sizeof(escaped));
- IPW_DEBUG_MERGE("Network '%s (%pM)' excluded "
- "because of ESSID mismatch: '%s'.\n",
- escaped, network->bssid,
+ IPW_DEBUG_MERGE("Network '%s (%pM)' excluded because of ESSID mismatch: '%s'\n",
+ print_ssid(escaped, network->ssid,
+ network->ssid_len),
+ network->bssid,
print_ssid(ssid, priv->essid,
priv->essid_len));
return 0;
@@ -5770,14 +5767,11 @@ static int ipw_best_network(struct ipw_priv *priv,
((network->ssid_len != priv->essid_len) ||
memcmp(network->ssid, priv->essid,
min(network->ssid_len, priv->essid_len)))) {
- char escaped[IW_ESSID_MAX_SIZE * 2 + 1];
- strncpy(escaped,
- print_ssid(ssid, network->ssid,
- network->ssid_len),
- sizeof(escaped));
- IPW_DEBUG_ASSOC("Network '%s (%pM)' excluded "
- "because of ESSID mismatch: '%s'.\n",
- escaped, network->bssid,
+ DECLARE_SSID_BUF(escaped);
+ IPW_DEBUG_ASSOC("Network '%s (%pM)' excluded because of ESSID mismatch: '%s'\n",
+ print_ssid(escaped, network->ssid,
+ network->ssid_len),
+ network->bssid,
print_ssid(ssid, priv->essid,
priv->essid_len));
return 0;
@@ -5787,13 +5781,11 @@ static int ipw_best_network(struct ipw_priv *priv,
/* If the old network rate is better than this one, don't bother
* testing everything else. */
if (match->network && match->network->stats.rssi > network->stats.rssi) {
- char escaped[IW_ESSID_MAX_SIZE * 2 + 1];
- strncpy(escaped,
- print_ssid(ssid, network->ssid, network->ssid_len),
- sizeof(escaped));
- IPW_DEBUG_ASSOC("Network '%s (%pM)' excluded because "
- "'%s (%pM)' has a stronger signal.\n",
- escaped, network->bssid,
+ DECLARE_SSID_BUF(escaped);
+ IPW_DEBUG_ASSOC("Network '%s (%pM)' excluded because '%s (%pM)' has a stronger signal\n",
+ print_ssid(escaped, network->ssid,
+ network->ssid_len),
+ network->bssid,
print_ssid(ssid, match->network->ssid,
match->network->ssid_len),
match->network->bssid);
next prev parent reply other threads:[~2013-01-07 3:19 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-01-05 13:41 [PATCH] drivers/net/wireless/ipw2x00: use strlcpy instead of strncpy Chen Gang
2013-01-05 14:42 ` Joe Perches
2013-01-07 2:49 ` Chen Gang
[not found] ` <50EA37CE.1090901-bOixZGp5f+dBDgjK7y7TUQ@public.gmane.org>
2013-01-07 2:57 ` Chen Gang F T
2013-01-07 3:19 ` Joe Perches [this message]
2013-01-07 3:42 ` Chen Gang F T
2013-01-07 4:49 ` [RFC PATCH] vsprintf: Add %p*D extension for 80211 SSIDs Joe Perches
2013-01-07 6:07 ` Chen Gang
[not found] ` <50EA6612.6010506-bOixZGp5f+dBDgjK7y7TUQ@public.gmane.org>
2013-01-07 6:37 ` Joe Perches
2013-01-07 6:58 ` Chen Gang
2013-01-07 7:47 ` Johannes Berg
2013-01-07 17:22 ` Joe Perches
2013-01-08 2:57 ` Chen Gang
[not found] ` <50EB8B1A.9000404-bOixZGp5f+dBDgjK7y7TUQ@public.gmane.org>
2013-01-08 3:11 ` Joe Perches
2013-01-08 3:20 ` Chen Gang
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=1357528746.4940.31.camel@joe-AO722 \
--to=joe@perches.com \
--cc=gang.chen@asianux.com \
--cc=linux-wireless@vger.kernel.org \
--cc=linville@tuxdriver.com \
--cc=netdev@vger.kernel.org \
--cc=stas.yakovlev@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).