From 5c0954afffe223ea61ea42dbc74ec7dbdc3663a1 Mon Sep 17 00:00:00 2001
From: HAOYUatHZ <37070449+HAOYUatHZ@users.noreply.github.com>
Date: Mon, 3 Sep 2018 22:47:20 +0800
Subject: [PATCH] p2p/discv5: make idx bounds checking more sound (#17571)

---
 p2p/discv5/net.go | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/p2p/discv5/net.go b/p2p/discv5/net.go
index b93c93d64..a6cabf080 100644
--- a/p2p/discv5/net.go
+++ b/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
-- 
GitLab