Browse Source

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.
Jouni Malinen 14 years ago
parent
commit
4e0c025d13
1 changed files with 3 additions and 2 deletions
  1. 3 2
      src/p2p/p2p_parse.c

+ 3 - 2
src/p2p/p2p_parse.c

@@ -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--;
 		}
 		}