]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
UBSan: Avoid a warning on signed left shift
authorJouni Malinen <j@w1.fi>
Sat, 23 Feb 2019 16:43:38 +0000 (18:43 +0200)
committerJouni Malinen <j@w1.fi>
Mon, 25 Feb 2019 17:48:49 +0000 (19:48 +0200)
Use unsigned 1 (1U) instead of signed (1) when doing left shift that
could potentially need to use all bits of the 32-bit unsigned variable.

radius_server.c:2254:14: runtime error: left shift of 1 by 31 places cannot be represented in type 'int'

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

index aa78cbae63a8d318f5743a8a47ee96d1d5fb1b81..1c15c2c3f907c1e68817d2b5a0e141c17e01857a 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * RADIUS authentication server
- * Copyright (c) 2005-2009, 2011-2014, Jouni Malinen <j@w1.fi>
+ * Copyright (c) 2005-2009, 2011-2019, Jouni Malinen <j@w1.fi>
  *
  * This software may be distributed under the terms of the BSD license.
  * See README for more details.
@@ -2251,7 +2251,7 @@ radius_server_read_clients(const char *client_file, int ipv6)
                        entry->addr.s_addr = addr.s_addr;
                        val = 0;
                        for (i = 0; i < mask; i++)
-                               val |= 1 << (31 - i);
+                               val |= 1U << (31 - i);
                        entry->mask.s_addr = htonl(val);
                }
 #ifdef CONFIG_IPV6