public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [patch] Use unsigned constants for ICMP6 filters [BZ #22489]
@ 2020-04-24 21:35 DJ Delorie
  2020-04-25  8:53 ` Andreas Schwab
  2020-04-26  8:03 ` Florian Weimer
  0 siblings, 2 replies; 16+ messages in thread
From: DJ Delorie @ 2020-04-24 21:35 UTC (permalink / raw)
  To: libc-alpha


https://sourceware.org/bugzilla/show_bug.cgi?id=22489

The patch in the bz applies and builds without change.  I added my
analysis of the failure (newer gcc's give a much more useful message
;) although it's pretty obvious in retrospect.

Only four lines changed, well under the assignment threshold.

From: Sergey <s.korolev@ndmsystems.com>
Date: Fri, 24 Apr 2020 17:18:41 -0400
Subject: Use unsigned constants for ICMP6 filters [BZ #22489]

The core problem here is that the bitfields are unsigned but
the computed constants are signed.  This patch forces the computed
constants to be unsigned. - DJ

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));


^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2020-05-12  7:35 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-24 21:35 [patch] Use unsigned constants for ICMP6 filters [BZ #22489] DJ Delorie
2020-04-25  8:53 ` Andreas Schwab
2020-04-25 17:15   ` DJ Delorie
2020-04-25 17:48     ` Andreas Schwab
2020-04-25 21:23       ` DJ Delorie
2020-04-25 21:30         ` Andreas Schwab
2020-04-25 21:41           ` DJ Delorie
2020-04-26 11:25             ` Alexander Monakov
2020-04-26 11:56               ` Florian Weimer
2020-04-30 20:47                 ` DJ Delorie
2020-05-03 20:23                   ` Florian Weimer
2020-05-08 20:10                     ` DJ Delorie
2020-05-08 20:22                       ` Florian Weimer
2020-05-11 21:09                         ` DJ Delorie
2020-05-12  7:35                       ` Andreas Schwab
2020-04-26  8:03 ` Florian Weimer

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).