Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

netfilter: uapi: Avoid undefined left-shift in xt_sctp.h

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>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>

authored by

Phil Sutter and committed by
Pablo Neira Ayuso
16416655 0b9173f4

+3 -3
+3 -3
include/uapi/linux/netfilter/xt_sctp.h
··· 41 41 #define SCTP_CHUNKMAP_SET(chunkmap, type) \ 42 42 do { \ 43 43 (chunkmap)[type / bytes(__u32)] |= \ 44 - 1 << (type % bytes(__u32)); \ 44 + 1u << (type % bytes(__u32)); \ 45 45 } while (0) 46 46 47 47 #define SCTP_CHUNKMAP_CLEAR(chunkmap, type) \ 48 48 do { \ 49 49 (chunkmap)[type / bytes(__u32)] &= \ 50 - ~(1 << (type % bytes(__u32))); \ 50 + ~(1u << (type % bytes(__u32))); \ 51 51 } while (0) 52 52 53 53 #define SCTP_CHUNKMAP_IS_SET(chunkmap, type) \ 54 54 ({ \ 55 55 ((chunkmap)[type / bytes (__u32)] & \ 56 - (1 << (type % bytes (__u32)))) ? 1: 0; \ 56 + (1u << (type % bytes (__u32)))) ? 1: 0; \ 57 57 }) 58 58 59 59 #define SCTP_CHUNKMAP_RESET(chunkmap) \