Fix crash when peers have sent undersized bitfields and we get the torrent info
This commit is contained in:
parent
1fab765329
commit
63c5ca1f01
|
@ -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()]
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue