File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -30,12 +30,12 @@ func hashIPBlock(ip ipblock.IPBlock) uint32 {
3030 binary .BigEndian .PutUint64 (buf [:], data )
3131
3232 hash := xxh3 .Hash (buf [:])
33- return uint32 (hash ) // #nosec G115 -- expected truncation
33+ return uint32 (hash & 0xffffffff )
3434}
3535
3636func hashUUID (id uuid.UUID ) uint32 {
3737 hash := xxh3 .Hash (id [:])
38- return uint32 (hash ) // #nosec G115 -- expected truncation
38+ return uint32 (hash & 0xffffffff )
3939}
4040
4141type InstanceState struct {
Original file line number Diff line number Diff line change @@ -28,7 +28,7 @@ type ExpireMap[K comparable, V any] struct {
2828// fastModulo calculates x % n without using the modulo operator (~4x faster).
2929// Reference: https://lemire.me/blog/2016/06/27/a-fast-alternative-to-the-modulo-reduction/
3030func fastModulo (x , n uint32 ) uint32 {
31- return uint32 ((uint64 (x ) * uint64 (n )) >> 32 ) //nolint:gosec
31+ return uint32 ((uint64 (x ) * uint64 (n )) >> 32 )
3232}
3333
3434func NewExpireMap [K comparable , V any ](hash func (K ) uint32 ) * ExpireMap [K , V ] {
Original file line number Diff line number Diff line change @@ -77,7 +77,7 @@ func (b IPBlock) ToIPNet(cfg Config) *net.IPNet {
7777
7878 ip := make (net.IP , 16 )
7979 for i := range 8 {
80- ip [7 - i ] = byte (b .data >> (8 * i ))
80+ ip [7 - i ] = byte (( b .data >> (8 * i )) & 0xff )
8181 }
8282 return & net.IPNet {
8383 IP : ip ,
You can’t perform that action at this time.
0 commit comments