File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 77package ipv6
88
99func (f * icmpv6Filter ) accept (typ ICMPType ) {
10+ if typ < 0 || int (typ >> 5 ) >= len (f .Filt ) {
11+ return
12+ }
1013 f .Filt [typ >> 5 ] |= 1 << (uint32 (typ ) & 31 )
1114}
1215
1316func (f * icmpv6Filter ) block (typ ICMPType ) {
17+ if typ < 0 || int (typ >> 5 ) >= len (f .Filt ) {
18+ return
19+ }
1420 f .Filt [typ >> 5 ] &^= 1 << (uint32 (typ ) & 31 )
1521}
1622
@@ -25,5 +31,8 @@ func (f *icmpv6Filter) setAll(block bool) {
2531}
2632
2733func (f * icmpv6Filter ) willBlock (typ ICMPType ) bool {
34+ if typ < 0 || int (typ >> 5 ) >= len (f .Filt ) {
35+ return false
36+ }
2837 return f .Filt [typ >> 5 ]& (1 << (uint32 (typ )& 31 )) == 0
2938}
Original file line number Diff line number Diff line change 55package ipv6
66
77func (f * icmpv6Filter ) accept (typ ICMPType ) {
8+ if typ < 0 || int (typ >> 5 ) >= len (f .Data ) {
9+ return
10+ }
811 f .Data [typ >> 5 ] &^= 1 << (uint32 (typ ) & 31 )
912}
1013
1114func (f * icmpv6Filter ) block (typ ICMPType ) {
15+ if typ < 0 || int (typ >> 5 ) >= len (f .Data ) {
16+ return
17+ }
1218 f .Data [typ >> 5 ] |= 1 << (uint32 (typ ) & 31 )
1319}
1420
@@ -23,5 +29,8 @@ func (f *icmpv6Filter) setAll(block bool) {
2329}
2430
2531func (f * icmpv6Filter ) willBlock (typ ICMPType ) bool {
32+ if typ < 0 || int (typ >> 5 ) >= len (f .Data ) {
33+ return false
34+ }
2635 return f .Data [typ >> 5 ]& (1 << (uint32 (typ )& 31 )) != 0
2736}
Original file line number Diff line number Diff line change 55package ipv6
66
77func (f * icmpv6Filter ) accept (typ ICMPType ) {
8+ if typ < 0 || int (typ >> 5 ) >= len (f .X__icmp6_filt ) {
9+ return
10+ }
811 f .X__icmp6_filt [typ >> 5 ] |= 1 << (uint32 (typ ) & 31 )
912}
1013
1114func (f * icmpv6Filter ) block (typ ICMPType ) {
15+ if typ < 0 || int (typ >> 5 ) >= len (f .X__icmp6_filt ) {
16+ return
17+ }
1218 f .X__icmp6_filt [typ >> 5 ] &^= 1 << (uint32 (typ ) & 31 )
1319}
1420
@@ -23,5 +29,8 @@ func (f *icmpv6Filter) setAll(block bool) {
2329}
2430
2531func (f * icmpv6Filter ) willBlock (typ ICMPType ) bool {
32+ if typ < 0 || int (typ >> 5 ) >= len (f .X__icmp6_filt ) {
33+ return false
34+ }
2635 return f .X__icmp6_filt [typ >> 5 ]& (1 << (uint32 (typ )& 31 )) == 0
2736}
Original file line number Diff line number Diff line change @@ -57,6 +57,13 @@ func TestICMPFilter(t *testing.T) {
5757 t .Errorf ("ipv6.ICMPFilter.Set(%v, true) failed" , typ )
5858 }
5959 }
60+ for _ , typ := range []ipv6.ICMPType {- 1 , 256 } {
61+ f .Accept (typ )
62+ f .Block (typ )
63+ if f .WillBlock (typ ) {
64+ t .Errorf ("ipv6.ICMPFilter.WillBlock(%v) = true; want false" , typ )
65+ }
66+ }
6067 }
6168}
6269
Original file line number Diff line number Diff line change 55package ipv6
66
77func (f * icmpv6Filter ) accept (typ ICMPType ) {
8+ if typ < 0 || int (typ >> 5 ) >= len (f .Filt ) {
9+ return
10+ }
811 f .Filt [typ >> 5 ] |= 1 << (uint32 (typ ) & 31 )
912
1013}
1114
1215func (f * icmpv6Filter ) block (typ ICMPType ) {
16+ if typ < 0 || int (typ >> 5 ) >= len (f .Filt ) {
17+ return
18+ }
1319 f .Filt [typ >> 5 ] &^= 1 << (uint32 (typ ) & 31 )
1420
1521}
@@ -25,5 +31,8 @@ func (f *icmpv6Filter) setAll(block bool) {
2531}
2632
2733func (f * icmpv6Filter ) willBlock (typ ICMPType ) bool {
34+ if typ < 0 || int (typ >> 5 ) >= len (f .Filt ) {
35+ return false
36+ }
2837 return f .Filt [typ >> 5 ]& (1 << (uint32 (typ )& 31 )) == 0
2938}
You can’t perform that action at this time.
0 commit comments