Use printf escaping in SSID-to-printable-string conversion
Instead of masking out non-ASCII characters with underscores, espace the SSID data using rules compatible with printf. Signed-hostap: Jouni Malinen <j@w1.fi>
This commit is contained in:
parent
0d7773b63f
commit
6bc1f95613
1 changed files with 6 additions and 9 deletions
|
@ -489,17 +489,14 @@ size_t printf_decode(u8 *buf, size_t maxlen, const char *str)
|
||||||
*/
|
*/
|
||||||
const char * wpa_ssid_txt(const u8 *ssid, size_t ssid_len)
|
const char * wpa_ssid_txt(const u8 *ssid, size_t ssid_len)
|
||||||
{
|
{
|
||||||
static char ssid_txt[33];
|
static char ssid_txt[32 * 4 + 1];
|
||||||
char *pos;
|
|
||||||
|
|
||||||
if (ssid_len > 32)
|
if (ssid == NULL) {
|
||||||
ssid_len = 32;
|
ssid_txt[0] = '\0';
|
||||||
os_memcpy(ssid_txt, ssid, ssid_len);
|
return ssid_txt;
|
||||||
ssid_txt[ssid_len] = '\0';
|
|
||||||
for (pos = ssid_txt; *pos != '\0'; pos++) {
|
|
||||||
if ((u8) *pos < 32 || (u8) *pos >= 127)
|
|
||||||
*pos = '_';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
printf_encode(ssid_txt, sizeof(ssid_txt), ssid, ssid_len);
|
||||||
return ssid_txt;
|
return ssid_txt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue