summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGreg Steuck <gnezdo@cvs.openbsd.org>2022-02-05 23:00:21 +0000
committerGreg Steuck <gnezdo@cvs.openbsd.org>2022-02-05 23:00:21 +0000
commit016758f8e8c9f54725ac96986a609f75ef900867 (patch)
treed5e14583c3c0ef206dc05b29275cc8a6e0d8853a
parent59cd164b8aa2488b10fe10857c92804f4483adf5 (diff)
Fix UB "shift-out-of-bounds" in battlestar
OK millert@
-rw-r--r--games/battlestar/extern.h8
1 files changed, 4 insertions, 4 deletions
diff --git a/games/battlestar/extern.h b/games/battlestar/extern.h
index dddae9ceb68..21f8dc72260 100644
--- a/games/battlestar/extern.h
+++ b/games/battlestar/extern.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: extern.h,v 1.21 2019/05/09 20:19:23 tedu Exp $ */
+/* $OpenBSD: extern.h,v 1.22 2022/02/05 23:00:20 gnezdo Exp $ */
/* $NetBSD: extern.h,v 1.5 1995/04/24 12:22:18 cgd Exp $ */
/*
@@ -39,9 +39,9 @@
#define OUTSIDE (position > 68 && position < 246 && position != 218)
#define rnd(x) arc4random_uniform(x)
#define max(a,b) ((a) < (b) ? (b) : (a))
-#define TestBit(array, index) (array[index/BITS] & (1 << (index % BITS)))
-#define SetBit(array, index) (array[index/BITS] |= (1 << (index % BITS)))
-#define ClearBit(array, index) (array[index/BITS] &= ~(1 << (index % BITS)))
+#define TestBit(array, index) (array[index/BITS] & (1U << (index % BITS)))
+#define SetBit(array, index) (array[index/BITS] |= (1U << (index % BITS)))
+#define ClearBit(array, index) (array[index/BITS] &= ~(1U << (index % BITS)))
/*
* These macros yield words to use with objects (followed but not preceded
* by spaces, or with no spaces if the expansion is the empty string).