From 518ae8c7cca899b6a0bf8d0bde9c9bb78a227b58 Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Tue, 18 Jul 2023 11:15:15 +0300 Subject: [PATCH] P2P: Do not print control characters in debug Do not print the received country code as characters if it includes control characters. Signed-off-by: Jouni Malinen --- src/p2p/p2p_parse.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/src/p2p/p2p_parse.c b/src/p2p/p2p_parse.c index 5d2299cb2..486d62863 100644 --- a/src/p2p/p2p_parse.c +++ b/src/p2p/p2p_parse.c @@ -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;