[nf] uapi: netfilter: Avoid undefined left-shift in xt_sctp.h
diff mbox series

Message ID 20191205123511.23932-1-phil@nwl.cc
State Accepted
Delegated to: Pablo Neira
Headers show
Series
  • [nf] uapi: netfilter: Avoid undefined left-shift in xt_sctp.h
Related show

Commit Message

Phil Sutter Dec. 5, 2019, 12:35 p.m. UTC
With 'bytes(__u32)' being 32, a left-shift of 31 may happen which is
undefined for the signed 32-bit value 1. Avoid this by declaring 1 as
unsigned.

Signed-off-by: Phil Sutter <phil@nwl.cc>
---
 include/uapi/linux/netfilter/xt_sctp.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Pablo Neira Ayuso Dec. 9, 2019, 11:52 a.m. UTC | #1
On Thu, Dec 05, 2019 at 01:35:11PM +0100, Phil Sutter wrote:
> With 'bytes(__u32)' being 32, a left-shift of 31 may happen which is
> undefined for the signed 32-bit value 1. Avoid this by declaring 1 as
> unsigned.

Applied, thanks Phil.

Patch
diff mbox series

diff --git a/include/uapi/linux/netfilter/xt_sctp.h b/include/uapi/linux/netfilter/xt_sctp.h
index 4bc6d1a087816..b4d804a9fccb2 100644
--- a/include/uapi/linux/netfilter/xt_sctp.h
+++ b/include/uapi/linux/netfilter/xt_sctp.h
@@ -41,19 +41,19 @@  struct xt_sctp_info {
 #define SCTP_CHUNKMAP_SET(chunkmap, type) 		\
 	do { 						\
 		(chunkmap)[type / bytes(__u32)] |= 	\
-			1 << (type % bytes(__u32));	\
+			1u << (type % bytes(__u32));	\
 	} while (0)
 
 #define SCTP_CHUNKMAP_CLEAR(chunkmap, type)		 	\
 	do {							\
 		(chunkmap)[type / bytes(__u32)] &= 		\
-			~(1 << (type % bytes(__u32)));	\
+			~(1u << (type % bytes(__u32)));	\
 	} while (0)
 
 #define SCTP_CHUNKMAP_IS_SET(chunkmap, type) 			\
 ({								\
 	((chunkmap)[type / bytes (__u32)] & 		\
-		(1 << (type % bytes (__u32)))) ? 1: 0;	\
+		(1u << (type % bytes (__u32)))) ? 1: 0;	\
 })
 
 #define SCTP_CHUNKMAP_RESET(chunkmap) \