]> Sergey Matveev's repositories - btrtrc.git/commitdiff
Fix crash when peers have sent undersized bitfields and we get the torrent info
authorMatt Joiner <anacrolix@gmail.com>
Fri, 29 Apr 2016 18:08:02 +0000 (04:08 +1000)
committerMatt Joiner <anacrolix@gmail.com>
Fri, 29 Apr 2016 18:08:02 +0000 (04:08 +1000)
connection.go

index 432519f0761ecd18967f7c826caa97567191019a..8d3c45ad5d2be57603ea141536c3d15f12a46ca3 100644 (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()]
        }