diff mbox series

wpa_supplicant: Convert SSID into printable form before printing

Message ID 20220615195543.237383-1-kaidong@chromium.org
State Accepted
Headers show
Series wpa_supplicant: Convert SSID into printable form before printing | expand

Commit Message

Kaidong Wang June 15, 2022, 7:55 p.m. UTC
SSID may include unprintable characters. This change converts
unprintable characters into printable form before printing SSID in the
function wpas_send_ctrl_req(). The conversion is based on the function
wpa_ssid_txt().

Signed-off-by: Kaidong Wang <kaidong@chromium.org>
---
 wpa_supplicant/wpas_glue.c | 24 ++----------------------
 1 file changed, 2 insertions(+), 22 deletions(-)

Comments

Jouni Malinen Nov. 27, 2022, 12:22 p.m. UTC | #1
On Wed, Jun 15, 2022 at 07:55:43PM +0000, Kaidong Wang wrote:
> SSID may include unprintable characters. This change converts
> unprintable characters into printable form before printing SSID in the
> function wpas_send_ctrl_req(). The conversion is based on the function
> wpa_ssid_txt().

Thanks, applied.
diff mbox series

Patch

diff --git a/wpa_supplicant/wpas_glue.c b/wpa_supplicant/wpas_glue.c
index d62914bc1..6f65aea2d 100644
--- a/wpa_supplicant/wpas_glue.c
+++ b/wpa_supplicant/wpas_glue.c
@@ -938,28 +938,8 @@  const char * wpa_supplicant_ctrl_req_to_string(enum wpa_ctrl_req_type field,
 void wpas_send_ctrl_req(struct wpa_supplicant *wpa_s, struct wpa_ssid *ssid,
 			const char *field_name, const char *txt)
 {
-	char *buf;
-	size_t buflen;
-	int len;
-
-	buflen = 100 + os_strlen(txt) + ssid->ssid_len;
-	buf = os_malloc(buflen);
-	if (buf == NULL)
-		return;
-	len = os_snprintf(buf, buflen, "%s-%d:%s needed for SSID ",
-			  field_name, ssid->id, txt);
-	if (os_snprintf_error(buflen, len)) {
-		os_free(buf);
-		return;
-	}
-	if (ssid->ssid && buflen > len + ssid->ssid_len) {
-		os_memcpy(buf + len, ssid->ssid, ssid->ssid_len);
-		len += ssid->ssid_len;
-		buf[len] = '\0';
-	}
-	buf[buflen - 1] = '\0';
-	wpa_msg(wpa_s, MSG_INFO, WPA_CTRL_REQ "%s", buf);
-	os_free(buf);
+	wpa_msg(wpa_s, MSG_INFO, WPA_CTRL_REQ "%s-%d:%s needed for SSID %s",
+		field_name, ssid->id, txt, wpa_ssid_txt(ssid->ssid, ssid->ssid_len));
 }