From 8eb1a3effe9cbd1336c9e10da9d4eae9785b3b53 Mon Sep 17 00:00:00 2001 From: Matt Joiner Date: Tue, 9 Jan 2018 17:26:01 +1100 Subject: [PATCH] Screen negative pieces Should fix #228. --- connection.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/connection.go b/connection.go index 34737d6b..f4bef805 100644 --- a/connection.go +++ b/connection.go @@ -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) { -- 2.48.1