Explorar o código

p2p/discv5: make idx bounds checking more sound (#17571)

HAOYUatHZ %!s(int64=7) %!d(string=hai) anos
pai
achega
5c0954afff
Modificáronse 1 ficheiros con 1 adicións e 1 borrados
  1. 1 1
      p2p/discv5/net.go

+ 1 - 1
p2p/discv5/net.go

@@ -1228,7 +1228,7 @@ func (net *Network) checkTopicRegister(data *topicRegister) (*pong, error) {
 	if rlpHash(data.Topics) != pongpkt.data.(*pong).TopicHash {
 		return nil, errors.New("topic hash mismatch")
 	}
-	if int(data.Idx) < 0 || int(data.Idx) >= len(data.Topics) {
+	if data.Idx >= uint(len(data.Topics)) {
 		return nil, errors.New("topic index out of range")
 	}
 	return pongpkt.data.(*pong), nil