]> Sergey Matveev's repositories - btrtrc.git/commitdiff
Piece offset computed incorrectly in Reader.readOnceAt
authorMatt Joiner <anacrolix@gmail.com>
Sun, 10 Jul 2016 13:00:52 +0000 (23:00 +1000)
committerMatt Joiner <anacrolix@gmail.com>
Sun, 10 Jul 2016 13:00:52 +0000 (23:00 +1000)
Possibly it was only wrong on the last piece in rare circumstances.

reader.go

index d1f9d2aaf7b424f762a9217dd941bffdae59dc37..b5eacf5b7d3f2bd9eaf04940c8cdb78fef5b4b61 100644 (file)
--- a/reader.go
+++ b/reader.go
@@ -170,7 +170,7 @@ func (r *Reader) readOnceAt(b []byte, pos int64, ctxErr *error) (n int, err erro
                b1 := b[:avail]
                pi := int(pos / r.t.Info().PieceLength)
                ip := r.t.Info().Piece(pi)
-               po := pos % ip.Length()
+               po := pos % r.t.Info().PieceLength
                missinggo.LimitLen(&b1, ip.Length()-po)
                n, err = r.t.readAt(b1, pos)
                if n != 0 {