]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
Validate MAC Address KDE length in the parser
authorJouni Malinen <quic_jouni@quicinc.com>
Mon, 5 Sep 2022 17:56:49 +0000 (20:56 +0300)
committerJouni Malinen <j@w1.fi>
Mon, 5 Sep 2022 17:56:49 +0000 (20:56 +0300)
Verify that the MAC Address KDE includes enough data to contain a MAC
address as a part of the parsing function so that each caller would not
need to verify this separately. None of the existing users of this
parser actually needed the MAC address value, so there was not any use
for the length field before. The updated design is more robust for
future uses and gets rid of that unused length field as well.

Signed-off-by: Jouni Malinen <quic_jouni@quicinc.com>
src/common/wpa_common.c
src/common/wpa_common.h

index c72467eecd19bd33a29f13232d1f2ab3c1e6c095..33d9bce393c6bb1c680ed60827e363f5026b9521 100644 (file)
@@ -3209,11 +3209,10 @@ static int wpa_parse_generic(const u8 *pos, struct wpa_eapol_ie_parse *ie)
                return 0;
        }
 
-       if (left > 2 && selector == RSN_KEY_DATA_MAC_ADDR) {
+       if (left >= ETH_ALEN && selector == RSN_KEY_DATA_MAC_ADDR) {
                ie->mac_addr = p;
-               ie->mac_addr_len = left;
-               wpa_hexdump(MSG_DEBUG, "WPA: MAC Address in EAPOL-Key",
-                           pos, dlen);
+               wpa_printf(MSG_DEBUG, "WPA: MAC Address in EAPOL-Key: " MACSTR,
+                          MAC2STR(ie->mac_addr));
                return 0;
        }
 
index a46b8857a403482bb7efa3dbff141fe40335711c..c01ddaa6bf0b872bcac76fdd8dadd827a369c6f3 100644 (file)
@@ -573,7 +573,6 @@ struct wpa_eapol_ie_parse {
        const u8 *gtk;
        size_t gtk_len;
        const u8 *mac_addr;
-       size_t mac_addr_len;
        const u8 *igtk;
        size_t igtk_len;
        const u8 *bigtk;