Skip to content

Commit

Permalink
netfilter: uapi: Avoid undefined left-shift in xt_sctp.h
Browse files Browse the repository at this point in the history
[ Upstream commit 164166558aacea01b99c8c8ffb710d930405ba69 ]

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 <[email protected]>
Signed-off-by: Pablo Neira Ayuso <[email protected]>
Signed-off-by: Sasha Levin <[email protected]>
  • Loading branch information
Phil Sutter authored and gregkh committed Jan 12, 2020
1 parent 829fde0 commit 962debe
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions include/uapi/linux/netfilter/xt_sctp.h
Original file line number Diff line number Diff line change
Expand Up @@ -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) \
Expand Down

0 comments on commit 962debe

Please sign in to comment.