Skip to content
This repository has been archived by the owner on Nov 14, 2024. It is now read-only.

Commit

Permalink
[nrf noup] zephyr: Fix message processing
Browse files Browse the repository at this point in the history
fixup! [nrf noup] Monitor supplicant state and inform applications

Incoming message has a pre-defined structure and isn't a arbitrary blob,
so, use the structure to parse properly.

This was working earlier as the payload was in the beginning of the
structure, but if we ever end up with a longer message then we would see
issues.

Signed-off-by: Chaitanya Tata <[email protected]>
  • Loading branch information
krish2718 committed Dec 5, 2023
1 parent 1df74c5 commit 07f1537
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions wpa_supplicant/wpa_cli_zephyr.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,13 +118,21 @@ static void wpa_cli_recv_pending(struct wpa_ctrl *ctrl)
size_t len = sizeof(buf) - 1;

if (wpa_ctrl_recv(ctrl, buf, &len) == 0) {
buf[len] = '\0';
if (strlen(buf) > 0) {
struct conn_msg *msg = (struct conn_msg *)buf;

msg->msg[msg->msg_len] = '\0';
wpa_printf(MSG_DEBUG, "Received len: %d, msg_len:%d - %s->END\n",
len, msg->msg_len, msg->msg);
if (msg->msg_len >= MAX_CTRL_MSG_LEN) {
wpa_printf(MSG_INFO, "Too long message received.\n");
continue;
}

if (msg->msg_len > 0) {
/* Only interested in CTRL-EVENTs */
if (strncmp(buf, "CTRL-EVENT", 10) == 0) {
wpa_printf(MSG_DEBUG, "Received event: %s\n", buf);
if (strncmp(msg->msg, "CTRL-EVENT", 10) == 0) {
send_wifi_mgmt_event("wlan0", NET_EVENT_WPA_SUPP_CMD_INT_EVENT,
(void *)&buf[0], strlen(buf));
msg->msg, msg->msg_len);
}
}
} else {
Expand Down

0 comments on commit 07f1537

Please sign in to comment.