]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
FILS: Do not leave error value in left counter
authorJouni Malinen <jouni@qca.qualcomm.com>
Fri, 24 Nov 2017 10:21:18 +0000 (12:21 +0200)
committerJouni Malinen <j@w1.fi>
Fri, 24 Nov 2017 10:26:38 +0000 (12:26 +0200)
If fils_decrypt_assoc() were to fail on the AP side, the previous
implementation could have continued through the response generation
using left = -1. That could have resulted in unexpected processing if
this value were to be used as the length of the remaining (unencrypted)
IEs. Fix this by not updating left in the failure case.

Fixes: 78815f3dde6e ("FILS: Decrypt Association Request elements and check Key-Auth (AP)")
Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
src/ap/ieee802_11.c

index 8f5ae87c2df0d84cd4ae20298df778bcf8f546e9..8a307f32b5d9620269f284ccc5f370a7f4e63471 100644 (file)
@@ -3221,6 +3221,8 @@ static void handle_assoc(struct hostapd_data *hapd,
        if (sta->auth_alg == WLAN_AUTH_FILS_SK ||
            sta->auth_alg == WLAN_AUTH_FILS_SK_PFS ||
            sta->auth_alg == WLAN_AUTH_FILS_PK) {
+               int res;
+
                /* The end of the payload is encrypted. Need to decrypt it
                 * before parsing. */
 
@@ -3230,13 +3232,14 @@ static void handle_assoc(struct hostapd_data *hapd,
                        goto fail;
                }
 
-               left = fils_decrypt_assoc(sta->wpa_sm, sta->fils_session, mgmt,
-                                         len, tmp, left);
-               if (left < 0) {
+               res = fils_decrypt_assoc(sta->wpa_sm, sta->fils_session, mgmt,
+                                        len, tmp, left);
+               if (res < 0) {
                        resp = WLAN_STATUS_UNSPECIFIED_FAILURE;
                        goto fail;
                }
                pos = tmp;
+               left = res;
        }
 #endif /* CONFIG_FILS */