]> Sergey Matveev's repositories - btrtrc.git/commitdiff
Screen negative pieces
authorMatt Joiner <anacrolix@gmail.com>
Tue, 9 Jan 2018 06:26:01 +0000 (17:26 +1100)
committerMatt Joiner <anacrolix@gmail.com>
Tue, 9 Jan 2018 06:26:01 +0000 (17:26 +1100)
Should fix #228.

connection.go

index 34737d6bbde12903d24a03f49fb6a8ed0c65b030..f4bef805698e119c04e68ee23ab5986df9b139d8 100644 (file)
@@ -667,7 +667,7 @@ func (cn *connection) raisePeerMinPieces(newMin int) {
 }
 
 func (cn *connection) peerSentHave(piece int) error {
-       if cn.t.haveInfo() && piece >= cn.t.numPieces() {
+       if cn.t.haveInfo() && piece >= cn.t.numPieces() || piece < 0 {
                return errors.New("invalid piece")
        }
        if cn.PeerHasPiece(piece) {