public inbox for glibc-cvs@sourceware.org help / color / mirror / Atom feed
From: DJ Delorie <dj@sourceware.org> To: glibc-cvs@sourceware.org Subject: [glibc] Use unsigned constants for ICMP6 filters [BZ #22489] Date: Mon, 11 May 2020 21:09:31 +0000 (GMT) [thread overview] Message-ID: <20200511210931.6EAA9385E830@sourceware.org> (raw) https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=c2d0411488c68a07cc22a5dd76fa37e952d2a66b commit c2d0411488c68a07cc22a5dd76fa37e952d2a66b Author: Sergey <s.korolev@ndmsystems.com> Date: Fri Apr 24 17:18:41 2020 -0400 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 Diff: --- inet/netinet/icmp6.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/inet/netinet/icmp6.h b/inet/netinet/icmp6.h index a75722887d..5fed0fbca1 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));
reply other threads:[~2020-05-11 21:09 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20200511210931.6EAA9385E830@sourceware.org \ --to=dj@sourceware.org \ --cc=glibc-cvs@sourceware.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).