OSDN Git Service

p2p/discv5: fix idx can be negative after uint convert to int(can cause crash) (...
authoryahtoo <yahtoo.ma@gmail.com>
Fri, 31 Aug 2018 05:48:40 +0000 (13:48 +0800)
committerPaladz <yzhu101@uottawa.ca>
Fri, 31 Aug 2018 05:48:40 +0000 (13:48 +0800)
p2p/discover/net.go

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