]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
UBSan: Use typecast to avoid unsigned integer overflow
authorJouni Malinen <j@w1.fi>
Sat, 23 Feb 2019 11:44:20 +0000 (13:44 +0200)
committerJouni Malinen <j@w1.fi>
Mon, 25 Feb 2019 17:48:46 +0000 (19:48 +0200)
iface->num_bss is unsigned integer, so need to explicit typecast it to
unsigned before decrementation by one even when the result is stored in
an unsigned integer.

../src/ap/hostapd.c:2185:26: runtime error: unsigned integer overflow: 0 - 1 cannot be represented in type 'unsigned long'

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

index 342585f9296ed922062c1e45daa7752704bc8fba..acab89edb73b9a69d061ea1df8c8884f3f7a0f5f 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * hostapd / Initialization and configuration
- * Copyright (c) 2002-2014, Jouni Malinen <j@w1.fi>
+ * Copyright (c) 2002-2019, Jouni Malinen <j@w1.fi>
  *
  * This software may be distributed under the terms of the BSD license.
  * See README for more details.
@@ -2182,7 +2182,7 @@ void hostapd_interface_deinit(struct hostapd_iface *iface)
        }
 #endif /* CONFIG_FST */
 
-       for (j = iface->num_bss - 1; j >= 0; j--) {
+       for (j = (int) iface->num_bss - 1; j >= 0; j--) {
                if (!iface->bss)
                        break;
                hostapd_bss_deinit(iface->bss[j]);