]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
P2P: Do not print control characters in debug
authorJouni Malinen <quic_jouni@quicinc.com>
Tue, 18 Jul 2023 08:15:15 +0000 (11:15 +0300)
committerJouni Malinen <j@w1.fi>
Tue, 18 Jul 2023 08:15:15 +0000 (11:15 +0300)
Do not print the received country code as characters if it includes
control characters.

Signed-off-by: Jouni Malinen <quic_jouni@quicinc.com>
src/p2p/p2p_parse.c

index 5d2299cb25c2e6420a2d18c690cd0c1f543d24bc..486d62863c2426e51983fea9be111f37552a4ceb 100644 (file)
@@ -93,6 +93,12 @@ static int p2p_parse_attribute(u8 id, const u8 *data, u16 len,
                        return -1;
                }
                msg->listen_channel = data;
+               if (has_ctrl_char(data, 2)) {
+                       wpa_printf(MSG_DEBUG,
+                                  "P2P: * Listen Channel: Country(binary) %02x %02x (0x%02x) Regulatory Class %d Channel Number %d",
+                                  data[0], data[1], data[2], data[3], data[4]);
+                       break;
+               }
                wpa_printf(MSG_DEBUG, "P2P: * Listen Channel: "
                           "Country %c%c(0x%02x) Regulatory "
                           "Class %d Channel Number %d", data[0], data[1],
@@ -110,6 +116,12 @@ static int p2p_parse_attribute(u8 id, const u8 *data, u16 len,
                        return -1;
                }
                msg->operating_channel = data;
+               if (has_ctrl_char(data, 2)) {
+                       wpa_printf(MSG_DEBUG,
+                                  "P2P: * Operating Channel: Country(binary) %02x %02x (0x%02x) Regulatory Class %d Channel Number %d",
+                                  data[0], data[1], data[2], data[3], data[4]);
+                       break;
+               }
                wpa_printf(MSG_DEBUG, "P2P: * Operating Channel: "
                           "Country %c%c(0x%02x) Regulatory "
                           "Class %d Channel Number %d", data[0], data[1],
@@ -123,8 +135,15 @@ static int p2p_parse_attribute(u8 id, const u8 *data, u16 len,
                }
                msg->channel_list = data;
                msg->channel_list_len = len;
-               wpa_printf(MSG_DEBUG, "P2P: * Channel List: Country String "
-                          "'%c%c(0x%02x)'", data[0], data[1], data[2]);
+               if (has_ctrl_char(data, 2)) {
+                       wpa_printf(MSG_DEBUG,
+                                  "P2P: * Channel List: Country String (binary) %02x %02x (0x%02x)",
+                                  data[0], data[1], data[2]);
+               } else {
+                       wpa_printf(MSG_DEBUG,
+                                  "P2P: * Channel List: Country String '%c%c(0x%02x)'",
+                                  data[0], data[1], data[2]);
+               }
                wpa_hexdump(MSG_MSGDUMP, "P2P: Channel List",
                            msg->channel_list, msg->channel_list_len);
                break;