diff mbox series

[4/5] ap: verify ATTR_MAC exists in NEW_STATION

Message ID 20240229181217.1503555-4-prestwoj@gmail.com (mailing list archive)
State Accepted, archived
Headers show
Series [1/5] ap: check that the last band_freq_attrs was set | expand

Checks

Context Check Description
tedd_an/pre-ci_am success Success
prestwoj/iwd-ci-gitlint success GitLint

Commit Message

James Prestwood Feb. 29, 2024, 6:12 p.m. UTC
Caught by static analysis, if ATTR_MAC was not in the message there
would be a memcpy with uninitialized bytes. In addition there is no
reason to memcpy twice. Instead 'mac' can be a const pointer which
both verifies it exists and removes the need for a second memcpy.
---
 src/ap.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/src/ap.c b/src/ap.c
index 25d1b8a3..a6f8f306 100644
--- a/src/ap.c
+++ b/src/ap.c
@@ -2963,7 +2963,7 @@  static void ap_handle_new_station(struct ap_state *ap, struct l_genl_msg *msg)
 	uint16_t type;
 	uint16_t len;
 	const void *data;
-	uint8_t mac[6];
+	const uint8_t *mac = NULL;
 	uint8_t *assoc_rsne = NULL;
 
 	if (!l_genl_attr_init(&attr, msg))
@@ -2983,12 +2983,12 @@  static void ap_handle_new_station(struct ap_state *ap, struct l_genl_msg *msg)
 			if (len != 6)
 				goto cleanup;
 
-			memcpy(mac, data, 6);
+			mac = data;
 			break;
 		}
 	}
 
-	if (!assoc_rsne)
+	if (!assoc_rsne || !mac)
 		goto cleanup;
 
 	/*