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

This commit is contained in:
HAOYUatHZ 2018-09-03 22:47:20 +08:00 committed by Felix Lange
parent 62e94895da
commit 5c0954afff
1 changed files with 1 additions and 1 deletions

View File

@ -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