From: James Prestwood <prestwoj@gmail.com>
To: iwd@lists.linux.dev
Cc: James Prestwood <prestwoj@gmail.com>
Subject: [PATCH 4/5] ap: verify ATTR_MAC exists in NEW_STATION
Date: Thu, 29 Feb 2024 10:12:16 -0800 [thread overview]
Message-ID: <20240229181217.1503555-4-prestwoj@gmail.com> (raw)
In-Reply-To: <20240229181217.1503555-1-prestwoj@gmail.com>
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 --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;
/*
--
2.34.1
next prev parent reply other threads:[~2024-02-29 18:12 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-29 18:12 [PATCH 1/5] ap: check that the last band_freq_attrs was set James Prestwood
2024-02-29 18:12 ` [PATCH 2/5] ap: allow va_end to get called in ap_handshake_event James Prestwood
2024-02-29 18:12 ` [PATCH 3/5] nl80211util: check l_genl_attr_recurse return in extract_nested James Prestwood
2024-02-29 18:12 ` James Prestwood [this message]
2024-02-29 18:12 ` [PATCH 5/5] ap: bail in ap_del_station if AP is going down James Prestwood
2024-02-29 20:38 ` [PATCH 1/5] ap: check that the last band_freq_attrs was set Denis Kenzior
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240229181217.1503555-4-prestwoj@gmail.com \
--to=prestwoj@gmail.com \
--cc=iwd@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox