Linux wireless drivers development
 help / color / mirror / Atom feed
From: Dan Williams <dcbw@redhat.com>
To: Johannes Berg <johannes@sipsolutions.net>
Cc: "John W. Linville" <linville@tuxdriver.com>,
	linux-wireless@vger.kernel.org
Subject: Re: [PATCH] wireless: consolidate on a single escape_essid implementation
Date: Thu, 25 Sep 2008 12:48:12 -0400	[thread overview]
Message-ID: <1222361292.14444.7.camel@localhost.localdomain> (raw)
In-Reply-To: <1222317983.10563.20.camel@johannes.berg>

On Thu, 2008-09-25 at 06:46 +0200, Johannes Berg wrote:
> On Wed, 2008-09-24 at 18:15 -0400, John W. Linville wrote:
> > This is also an excuse to create the long rumored lib80211 module...
> 
> Let's also take the chance to clean up the mess Intel has, once again,
> created here.
> 
> >  		switch (info_element->id) {
> >  		case MFIE_TYPE_SSID:
> > -			if (ieee80211_is_empty_essid(info_element->data,
> > -						     info_element->len)) {
> > +			if (is_empty_essid(info_element->data,
> > +					   info_element->len)) {
> >  				network->flags |= NETWORK_EMPTY_ESSID;
> >  				break;
> >  			}
> 
> You can remove the whole NETWORK_EMPTY_ESSID flag and this whole test;
> the code slightly below needs to take care to actually escape the SSID
> for the debug output.
> 
> > @@ -1411,7 +1412,7 @@ static int ieee80211_handle_assoc_resp(struct ieee80211_device *ieee, struct iee
> >  			network->mode |= IEEE_B;
> >  	}
> >  
> > -	if (ieee80211_is_empty_essid(network->ssid, network->ssid_len))
> > +	if (is_empty_essid(network->ssid, network->ssid_len))
> >  		network->flags |= NETWORK_EMPTY_ESSID;
> 
> drop the whole if
>  
> >  
> > -	if (ieee80211_is_empty_essid(network->ssid, network->ssid_len))
> > +	if (is_empty_essid(network->ssid, network->ssid_len))
> >  		network->flags |= NETWORK_EMPTY_ESSID;
> 
> ditto.
> 
> that leaves once place using the NETWORK_EMPTY_ESSID flag, in
> ieee80211_wx.c:
> 
>         /* Add the ESSID */
>         iwe.cmd = SIOCGIWESSID;
>         iwe.u.data.flags = 1;
>         if (network->flags & NETWORK_EMPTY_ESSID) {
>                 iwe.u.data.length = sizeof("<hidden>");
>                 start = iwe_stream_add_point(info, start, stop,
>                                              &iwe, "<hidden>");
>         } else {
>                 iwe.u.data.length = min(network->ssid_len, (u8) 32);
>                 start = iwe_stream_add_point(info, start, stop,
>                                              &iwe, network->ssid);
>         }
> 
> which is of course *completely* *wrong*. There's no excuse for messing
> up the values passed to userspace like that.
> 
> > +const char *escape_essid(const char *essid, u8 essid_len)
> > +{
> > +	static char escaped[IW_ESSID_MAX_SIZE * 2 + 1];
> > +	const char *s = essid;
> > +	char *d = escaped;
> > +
> > +	if (is_empty_essid(essid, essid_len)) {
> > +		memcpy(escaped, "<hidden>", sizeof("<hidden>"));
> > +		return escaped;
> > +	}
> 
> Once you've done the above, is_empty_essid is only used here. I'll leave
> it to you whether you want to print <hidden> or not, I'd prefer if the
> function was to just escape the ASCII-NULs as normal since then you can
> actually distinguish the various forms of hidden SSIDs which might help.
> Maybe that needs quotes around the escaped SSID then.
> 
> > +	essid_len = min(essid_len, (u8) IW_ESSID_MAX_SIZE);
> > +	while (essid_len--) {
> > +		if (*s == '\0') {
> > +			*d++ = '\\';
> > +			*d++ = '0';
> > +			s++;
> > +		} else {
> > +			*d++ = *s++;
> > +		}
> > +	}
> > +	*d = '\0';
> > +	return escaped;
> > +}
> > +EXPORT_SYMBOL(escape_essid);
> 
> Also, we could take the chance to stop making Jean's mistake in calling
> this thing the _E_SSID, there's no such thing, it's Jean's invention,
> based on his misguided thought that this might somehow be less confusing
> to the user.

+1

Dan


  parent reply	other threads:[~2008-09-25 16:49 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-09-24 22:15 [PATCH] wireless: consolidate on a single escape_essid implementation John W. Linville
2008-09-24 23:24 ` Luis R. Rodriguez
2008-09-24 23:32   ` John W. Linville
2008-09-25  0:21     ` Luis R. Rodriguez
2008-09-25  0:39       ` John W. Linville
2008-09-25  1:52         ` Luis R. Rodriguez
2008-09-25  6:34     ` Holger Schurig
2008-09-25  8:43       ` Johannes Berg
2008-09-25 16:57         ` Dan Williams
2008-09-26 11:08           ` Johannes Berg
2008-09-26 14:51             ` Johannes Berg
2008-09-26 14:57           ` Johannes Berg
2008-09-25 23:03   ` Dave
2008-09-25  4:46 ` Johannes Berg
2008-09-25  4:49   ` Johannes Berg
2008-09-25 16:47     ` Dan Williams
2008-09-25 16:48   ` Dan Williams [this message]
2008-09-25 21:00 ` Dave
2008-10-01  2:15 ` [PATCH 0/5] wireless: single escape_essid implementation and related cleanups John W. Linville
2008-10-01  2:15   ` [PATCH 1/5] wireless: consolidate on a single escape_essid implementation John W. Linville
2008-10-01  2:15     ` [PATCH 2/5] wireless: remove NETWORK_EMPTY_ESSID flag John W. Linville
2008-10-01  2:15       ` [PATCH 3/5] wireless: escape_ssid should handle non-printables John W. Linville
2008-10-01  2:15         ` [PATCH 4/5] wireless: use individual buffers for printing ssid values John W. Linville
2008-10-01  2:15           ` [PATCH 5/5] wireless: avoid some net/ieee80211.h vs. linux/ieee80211.h conflicts John W. Linville
2008-10-01  9:25   ` [PATCH 0/5] wireless: single escape_essid implementation and related cleanups Johannes Berg
2008-10-02 19:10   ` Dan Williams

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=1222361292.14444.7.camel@localhost.localdomain \
    --to=dcbw@redhat.com \
    --cc=johannes@sipsolutions.net \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox