History

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.

Phil Sutter committed 6 years ago

Commit 16416651 parent 0b9173f1 file · +3 −3Browse files

Showing the changes to include/uapi/linux (1 of 1 file). Show all

Unified · Split

include/uapi/linux/netfilter/xt_sctp.h+3−3
@@ -41,19 +41,19 @@ struct xt_sctp_info { · 40 unmodified lines
4141 #define SCTP_CHUNKMAP_SET(chunkmap, type) \
4242 do { \
4343 (chunkmap)[type / bytes(__u32)] |= \
44− 1 << (type % bytes(__u32)); \
44+ 1u << (type % bytes(__u32)); \
4545 } while (0)
4646
4747 #define SCTP_CHUNKMAP_CLEAR(chunkmap, type) \
4848 do { \
4949 (chunkmap)[type / bytes(__u32)] &= \
50− ~(1 << (type % bytes(__u32))); \
50+ ~(1u << (type % bytes(__u32))); \
5151 } while (0)
5252
5353 #define SCTP_CHUNKMAP_IS_SET(chunkmap, type) \
5454 ({ \
5555 ((chunkmap)[type / bytes (__u32)] & \
56− (1 << (type % bytes (__u32)))) ? 1: 0; \
56+ (1u << (type % bytes (__u32)))) ? 1: 0; \
5757 })
5858
5959 #define SCTP_CHUNKMAP_RESET(chunkmap) \