]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
UBSan: Avoid an unsigned integer overflow warning
authorJouni Malinen <j@w1.fi>
Sat, 23 Feb 2019 11:57:51 +0000 (13:57 +0200)
committerJouni Malinen <j@w1.fi>
Mon, 25 Feb 2019 17:48:49 +0000 (19:48 +0200)
ext_supp_rates_len would be 0 here, so decrementing it by 2 will result
in unsigned integer overflow even if that result is not actually used
anywhere. Avoid that to get rid of the UBSan warning.

tdls.c:1597:27: runtime error: unsigned integer overflow: 0 - 2 cannot be represented in type 'unsigned long'

Signed-off-by: Jouni Malinen <j@w1.fi>
src/rsn_supp/tdls.c

index 345b0c84d871c6847cdf71ada47e204c4115dd91..704c95e68616971f96e5f17bb10d0fc23df2e91b 100644 (file)
@@ -1594,7 +1594,7 @@ static int copy_supp_rates(const struct wpa_eapol_ie_parse *kde,
                peer->supp_rates, sizeof(peer->supp_rates),
                kde->supp_rates + 2, kde->supp_rates_len - 2,
                kde->ext_supp_rates ? kde->ext_supp_rates + 2 : NULL,
-               kde->ext_supp_rates_len - 2);
+               kde->ext_supp_rates ? kde->ext_supp_rates_len - 2 : 0);
        return 0;
 }