]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
P2P: Fix parsing of UTF-8 device names
authorJouni Malinen <jouni.malinen@atheros.com>
Tue, 26 Oct 2010 07:40:35 +0000 (10:40 +0300)
committerJouni Malinen <j@w1.fi>
Tue, 26 Oct 2010 07:40:35 +0000 (10:40 +0300)
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.

src/p2p/p2p_parse.c

index 25337a557ef2f2af2e97962e2e86058ff72a3c14..871badc311728d38676bcbc61daa70552fac445e 100644 (file)
@@ -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--;
                }