mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Joe Perches <joe@perches.com>
To: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: "John W. Linville" <linville@tuxdriver.com>,
	Johannes Berg <johannes@sipsolutions.net>,
	devel@driverdev.osuosl.org, linux-wireless@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [PATCH 3/6] lib80211: re-use string_escape_mem_any_np()
Date: Wed, 02 Jul 2014 06:43:31 -0700	[thread overview]
Message-ID: <1404308611.14624.78.camel@joe-AO725> (raw)
In-Reply-To: <1404307229-19186-4-git-send-email-andriy.shevchenko@linux.intel.com>

On Wed, 2014-07-02 at 16:20 +0300, Andy Shevchenko wrote:
> In kernel we have function to escape a given string. Let's use it instead of
> custom approach.
> 
> This fixes a bug. The current implementation wrongly prints octal numbers: only
> two first digits are used in case when 3 are required and the rest of the
> string ends up cut off.
[]
> diff --git a/net/wireless/lib80211.c b/net/wireless/lib80211.c
[]
> @@ -48,31 +49,10 @@ static void lib80211_crypt_deinit_handler(unsigned long data);
>  
>  const char *print_ssid(char *buf, const char *ssid, u8 ssid_len)
>  {
> -	const char *s = ssid;
>  	char *d = buf;
>  
>  	ssid_len = min_t(u8, ssid_len, IEEE80211_MAX_SSID_LEN);
> -	while (ssid_len--) {
> -		if (isprint(*s)) {
> -			*d++ = *s++;
> -			continue;
> -		}
> -
> -		*d++ = '\\';
> -		if (*s == '\0')
> -			*d++ = '0';
> -		else if (*s == '\n')
> -			*d++ = 'n';
> -		else if (*s == '\r')
> -			*d++ = 'r';
> -		else if (*s == '\t')
> -			*d++ = 't';
> -		else if (*s == '\\')
> -			*d++ = '\\';
> -		else
> -			d += snprintf(d, 3, "%03o", *s);
> -		s++;
> -	}
> +	d += string_escape_mem_any_np(ssid, ssid_len, buf, ~0UL, NULL);
>  	*d = '\0';
>  	return buf;
>  }

This code looks like it was adapted from the old print_mac
ethernet code that was eventually replaced by a vsprintf
pointer extension %pM

So a better way to do this might be to add and use yet
another vsprintf %p<foo> extension for ssids.



  reply	other threads:[~2014-07-02 13:43 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-02 13:20 [PATCH 0/6] lib / string_helpers: introduce string_escape_mem Andy Shevchenko
2014-07-02 13:20 ` [PATCH 1/6] lib / string_helpers: clean up test suite Andy Shevchenko
2014-07-02 21:54   ` Andrew Morton
2014-07-03  9:34     ` Andy Shevchenko
2014-07-02 13:20 ` [PATCH 2/6] lib / string_helpers: introduce string_escape_mem() Andy Shevchenko
2014-07-02 22:01   ` Andrew Morton
2014-07-03  9:53     ` Andy Shevchenko
2014-07-02 13:20 ` [PATCH 3/6] lib80211: re-use string_escape_mem_any_np() Andy Shevchenko
2014-07-02 13:43   ` Joe Perches [this message]
2014-07-02 14:06     ` Andy Shevchenko
2014-07-02 16:30       ` Joe Perches
2014-07-03 10:49         ` Andy Shevchenko
2014-07-02 13:20 ` [PATCH 4/6] staging: wlan-ng: re-use string_escape_mem() Andy Shevchenko
2014-07-02 13:20 ` [PATCH 5/6] staging: rtl8192e: " Andy Shevchenko
2014-07-02 13:35   ` Joe Perches
2014-07-02 14:11     ` Andy Shevchenko
2014-07-02 13:20 ` [PATCH 6/6] staging: rtl8192u: " Andy Shevchenko

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=1404308611.14624.78.camel@joe-AO725 \
    --to=joe@perches.com \
    --cc=akpm@linux-foundation.org \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=johannes@sipsolutions.net \
    --cc=linux-kernel@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®