From: Matt Joiner Date: Fri, 29 Apr 2016 18:08:02 +0000 (+1000) Subject: Fix crash when peers have sent undersized bitfields and we get the torrent info X-Git-Tag: v1.0.0~769 X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=63c5ca1f0188f73b696fb00bf61a4ca1d343a2b7;p=btrtrc.git Fix crash when peers have sent undersized bitfields and we get the torrent info --- 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()] }