]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
Fix handle_auth_cb() message length check regression
authorJouni Malinen <jouni@codeaurora.org>
Mon, 22 Feb 2021 22:30:09 +0000 (00:30 +0200)
committerJouni Malinen <j@w1.fi>
Mon, 22 Feb 2021 22:30:09 +0000 (00:30 +0200)
Reordering of code in handle_auth_cb() when adding support for full
station state messaged up frame length checks. The length was originally
tested before looking at the payload of the frame and that is obviously
the correct location for that check. The location after those full state
state changes was after having read six octets of the payload which did
not help at all since there was no addition accesses to the payload
after that check.

Move the payload length check to appropriate place to get this extra
level of protection behaving in the expected manner. Since this is a TX
status callback handler, the frame payload is from a locally generated
Authentication frame and as such, it will be long enough to include
these fields in production use cases. Anyway, better keep this check in
working condition.

Fixes: bb598c3bdd06 ("AP: Add support for full station state")
Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
src/ap/ieee802_11.c

index 233da7bfc22e999d4cf8a856c7ef85b18722bd69..40d4a3381786e133797ab67b50633764dd82a44b 100644 (file)
@@ -6202,6 +6202,15 @@ static void handle_auth_cb(struct hostapd_data *hapd,
                return;
        }
 
+       if (len < IEEE80211_HDRLEN + sizeof(mgmt->u.auth)) {
+               wpa_printf(MSG_INFO, "handle_auth_cb - too short payload (len=%lu)",
+                          (unsigned long) len);
+               auth_alg = 0;
+               auth_transaction = 0;
+               status_code = WLAN_STATUS_UNSPECIFIED_FAILURE;
+               goto fail;
+       }
+
        auth_alg = le_to_host16(mgmt->u.auth.auth_alg);
        auth_transaction = le_to_host16(mgmt->u.auth.auth_transaction);
        status_code = le_to_host16(mgmt->u.auth.status_code);
@@ -6213,12 +6222,6 @@ static void handle_auth_cb(struct hostapd_data *hapd,
                goto fail;
        }
 
-       if (len < IEEE80211_HDRLEN + sizeof(mgmt->u.auth)) {
-               wpa_printf(MSG_INFO, "handle_auth_cb - too short payload (len=%lu)",
-                          (unsigned long) len);
-               goto fail;
-       }
-
        if (status_code == WLAN_STATUS_SUCCESS &&
            ((auth_alg == WLAN_AUTH_OPEN && auth_transaction == 2) ||
             (auth_alg == WLAN_AUTH_SHARED_KEY && auth_transaction == 4))) {