P2P: Fix parsing of UTF-8 device names

The control character verification was supposed to only replace
bytes 0..31, not 0..31 and 128..255 as happened on systems where
char is signed.
This commit is contained in:
Jouni Malinen 2010-10-26 10:40:35 +03:00 committed by Jouni Malinen
parent be88391dee
commit 4e0c025d13

View File

@ -166,7 +166,8 @@ static int p2p_parse_attribute(u8 id, const u8 *data, u16 len,
for (i = 0; i < nlen; i++) { for (i = 0; i < nlen; i++) {
if (msg->device_name[i] == '\0') if (msg->device_name[i] == '\0')
break; break;
if (msg->device_name[i] < 32) if (msg->device_name[i] > 0 &&
msg->device_name[i] < 32)
msg->device_name[i] = '_'; msg->device_name[i] = '_';
} }
wpa_printf(MSG_DEBUG, "P2P: * Device Info: addr " MACSTR wpa_printf(MSG_DEBUG, "P2P: * Device Info: addr " MACSTR
@ -563,7 +564,7 @@ static int p2p_group_info_text(const u8 *gi, size_t gi_len, char *buf,
name[cli->dev_name_len] = '\0'; name[cli->dev_name_len] = '\0';
count = (int) cli->dev_name_len - 1; count = (int) cli->dev_name_len - 1;
while (count >= 0) { while (count >= 0) {
if (name[count] < 32) if (name[count] > 0 && name[count] < 32)
name[count] = '_'; name[count] = '_';
count--; count--;
} }