aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey <s.korolev@ndmsystems.com>2020-04-24 17:18:41 -0400
committerDJ Delorie <dj@redhat.com>2020-05-11 17:09:05 -0400
commitc2d0411488c68a07cc22a5dd76fa37e952d2a66b (patch)
tree54a88f59533c6ef46c27fd7bca207e178be4fc0a
parent6fcb0272f76721a45e33061404120907e8c5dae4 (diff)
downloadglibc-c2d0411488c68a07cc22a5dd76fa37e952d2a66b.zip
glibc-c2d0411488c68a07cc22a5dd76fa37e952d2a66b.tar.gz
glibc-c2d0411488c68a07cc22a5dd76fa37e952d2a66b.tar.bz2
Use unsigned constants for ICMP6 filters [BZ #22489]
The core problem here is that the filter array elements are unsigned but the computed constants are signed. This both causes a signededness conversion at the &= step and may cause undefined behavior if the MSB is being modified. This patch uses unsigned constants to avoid both cases. - DJ
-rw-r--r--inet/netinet/icmp6.h8
1 files changed, 4 insertions, 4 deletions
diff --git a/inet/netinet/icmp6.h b/inet/netinet/icmp6.h
index a757228..5fed0fb 100644
--- a/inet/netinet/icmp6.h
+++ b/inet/netinet/icmp6.h
@@ -85,16 +85,16 @@ struct icmp6_hdr
#define ICMP6_PARAMPROB_OPTION 2 /* unrecognized IPv6 option */
#define ICMP6_FILTER_WILLPASS(type, filterp) \
- ((((filterp)->icmp6_filt[(type) >> 5]) & (1 << ((type) & 31))) == 0)
+ ((((filterp)->icmp6_filt[(type) >> 5]) & (1U << ((type) & 31))) == 0)
#define ICMP6_FILTER_WILLBLOCK(type, filterp) \
- ((((filterp)->icmp6_filt[(type) >> 5]) & (1 << ((type) & 31))) != 0)
+ ((((filterp)->icmp6_filt[(type) >> 5]) & (1U << ((type) & 31))) != 0)
#define ICMP6_FILTER_SETPASS(type, filterp) \
- ((((filterp)->icmp6_filt[(type) >> 5]) &= ~(1 << ((type) & 31))))
+ ((((filterp)->icmp6_filt[(type) >> 5]) &= ~(1U << ((type) & 31))))
#define ICMP6_FILTER_SETBLOCK(type, filterp) \
- ((((filterp)->icmp6_filt[(type) >> 5]) |= (1 << ((type) & 31))))
+ ((((filterp)->icmp6_filt[(type) >> 5]) |= (1U << ((type) & 31))))
#define ICMP6_FILTER_SETPASSALL(filterp) \
memset (filterp, 0, sizeof (struct icmp6_filter));