]> git.ipfire.org Git - thirdparty/iptables.git/commitdiff
include: Avoid undefined left-shift in xt_sctp.h
authorPhil Sutter <phil@nwl.cc>
Thu, 5 Dec 2019 12:35:25 +0000 (13:35 +0100)
committerPhil Sutter <phil@nwl.cc>
Fri, 29 May 2020 18:27:49 +0000 (20:27 +0200)
Pull the fix in kernel commit 164166558aace ("netfilter: uapi: Avoid
undefined left-shift in xt_sctp.h") into iptables repository. The
original description is:

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>
Acked-by: Pablo Neira Ayuso <pablo@netfilter.org>
include/linux/netfilter/xt_sctp.h

index a501e6196905d082c81a2d546523933d65de7168..5b28525a2482a8c245edfe3a5e169ef4f95fe297 100644 (file)
@@ -40,19 +40,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) \