From 63c5ca1f0188f73b696fb00bf61a4ca1d343a2b7 Mon Sep 17 00:00:00 2001 From: Matt Joiner Date: Sat, 30 Apr 2016 04:08:02 +1000 Subject: [PATCH] Fix crash when peers have sent undersized bitfields and we get the torrent info --- connection.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/connection.go b/connection.go index 432519f0..8d3c45ad 100644 --- a/connection.go +++ b/connection.go @@ -629,7 +629,7 @@ func (cn *connection) peerSentBitfield(bf []bool) error { // We know that the last byte means that at most the last 7 bits are // wasted. cn.raisePeerMinPieces(len(bf) - 7) - if cn.t.haveInfo() { + if cn.t.haveInfo() && len(bf) > cn.t.numPieces() { // Ignore known excess pieces. bf = bf[:cn.t.numPieces()] } -- 2.48.1