lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Wed,  2 Jul 2014 16:20:26 +0300
From:	Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
To:	"John W. Linville" <linville@...driver.com>,
	Johannes Berg <johannes@...solutions.net>,
	devel@...verdev.osuosl.org, linux-wireless@...r.kernel.org,
	linux-kernel@...r.kernel.org,
	Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
	Andrew Morton <akpm@...ux-foundation.org>
Cc:	Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
Subject: [PATCH 3/6] lib80211: re-use string_escape_mem_any_np()

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.

Additionally the \f, \v, \a, and \e are escaped to their alphabetic
representation. It's safe to do since the print_ssid() is currently used for
messaging only.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
---
 net/wireless/lib80211.c | 24 ++----------------------
 1 file changed, 2 insertions(+), 22 deletions(-)

diff --git a/net/wireless/lib80211.c b/net/wireless/lib80211.c
index a55c27b..0c2f67b 100644
--- a/net/wireless/lib80211.c
+++ b/net/wireless/lib80211.c
@@ -22,6 +22,7 @@
 #include <linux/init.h>
 #include <linux/slab.h>
 #include <linux/string.h>
+#include <linux/string_helpers.h>
 
 #include <net/lib80211.h>
 
@@ -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;
 }
-- 
2.0.0

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ