Parcourir la 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 il y a 14 ans
Parent
commit
4e0c025d13
1 fichiers modifiés avec 3 ajouts et 2 suppressions
  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++) {
 			if (msg->device_name[i] == '\0')
 				break;
-			if (msg->device_name[i] < 32)
+			if (msg->device_name[i] > 0 &&
+			    msg->device_name[i] < 32)
 				msg->device_name[i] = '_';
 		}
 		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';
 		count = (int) cli->dev_name_len - 1;
 		while (count >= 0) {
-			if (name[count] < 32)
+			if (name[count] > 0 && name[count] < 32)
 				name[count] = '_';
 			count--;
 		}