diff options
Diffstat (limited to 'net/wireless')
-rw-r--r-- | net/wireless/lib80211.c | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/net/wireless/lib80211.c b/net/wireless/lib80211.c index 872cc8dc00a3..b8e34d31e757 100644 --- a/net/wireless/lib80211.c +++ b/net/wireless/lib80211.c | |||
@@ -6,6 +6,7 @@ | |||
6 | */ | 6 | */ |
7 | 7 | ||
8 | #include <linux/module.h> | 8 | #include <linux/module.h> |
9 | #include <linux/ctype.h> | ||
9 | #include <linux/ieee80211.h> | 10 | #include <linux/ieee80211.h> |
10 | 11 | ||
11 | #include <net/lib80211.h> | 12 | #include <net/lib80211.h> |
@@ -20,19 +21,31 @@ MODULE_LICENSE("GPL"); | |||
20 | 21 | ||
21 | const char *escape_ssid(const char *ssid, u8 ssid_len) | 22 | const char *escape_ssid(const char *ssid, u8 ssid_len) |
22 | { | 23 | { |
23 | static char escaped[IEEE80211_MAX_SSID_LEN * 2 + 1]; | 24 | static char escaped[IEEE80211_MAX_SSID_LEN * 4 + 1]; |
24 | const char *s = ssid; | 25 | const char *s = ssid; |
25 | char *d = escaped; | 26 | char *d = escaped; |
26 | 27 | ||
27 | ssid_len = min_t(u8, ssid_len, IEEE80211_MAX_SSID_LEN); | 28 | ssid_len = min_t(u8, ssid_len, IEEE80211_MAX_SSID_LEN); |
28 | while (ssid_len--) { | 29 | while (ssid_len--) { |
29 | if (*s == '\0') { | 30 | if (isprint(*s)) { |
30 | *d++ = '\\'; | ||
31 | *d++ = '0'; | ||
32 | s++; | ||
33 | } else { | ||
34 | *d++ = *s++; | 31 | *d++ = *s++; |
32 | continue; | ||
35 | } | 33 | } |
34 | |||
35 | *d++ = '\\'; | ||
36 | if (*s == '\0') | ||
37 | *d++ = '0'; | ||
38 | else if (*s == '\n') | ||
39 | *d++ = 'n'; | ||
40 | else if (*s == '\r') | ||
41 | *d++ = 'r'; | ||
42 | else if (*s == '\t') | ||
43 | *d++ = 't'; | ||
44 | else if (*s == '\\') | ||
45 | *d++ = '\\'; | ||
46 | else | ||
47 | d += snprintf(d, 3, "%03o", *s); | ||
48 | s++; | ||
36 | } | 49 | } |
37 | *d = '\0'; | 50 | *d = '\0'; |
38 | return escaped; | 51 | return escaped; |