Screen negative pieces

Should fix #228.
This commit is contained in:
Matt Joiner 2018-01-09 17:26:01 +11:00
parent aa42704976
commit 8eb1a3effe
1 changed files with 1 additions and 1 deletions

View 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) {