Fix crash when peers have sent undersized bitfields and we get the torrent info

This commit is contained in:
Matt Joiner 2016-04-30 04:08:02 +10:00
parent 1fab765329
commit 63c5ca1f01
1 changed files with 1 additions and 1 deletions

View File

@ -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()]
}