]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
UBSan: Split loop index decrementation into a separate step
authorJouni Malinen <j@w1.fi>
Sat, 23 Feb 2019 16:14:29 +0000 (18:14 +0200)
committerJouni Malinen <j@w1.fi>
Mon, 25 Feb 2019 17:48:49 +0000 (19:48 +0200)
Avoid an unnecessary unsigned integer overflow warning due to loop index
j-- use.

hostapd.c:661:10: runtime error: unsigned integer overflow: 0 - 1 cannot be represented in type 'unsigned int'

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

index 5dcec47e1aaaffa2c10e51cac3a6e386a3702652..60943cd02db4e8a12c81b0ef50bebf4fb13c77e2 100644 (file)
@@ -658,8 +658,10 @@ static int hostapd_validate_bssid_configuration(struct hostapd_iface *iface)
        for (i = 5; i > 5 - j; i--)
                mask[i] = 0;
        j = bits % 8;
-       while (j--)
+       while (j) {
+               j--;
                mask[i] <<= 1;
+       }
 
 skip_mask_ext:
        wpa_printf(MSG_DEBUG, "BSS count %lu, BSSID mask " MACSTR " (%d bits)",