]> Sergey Matveev's repositories - btrtrc.git/commitdiff
torrentfs: Reading an offset past the end of a file caused out of bounds panic
authorMatt Joiner <anacrolix@gmail.com>
Wed, 25 Jun 2014 15:36:25 +0000 (01:36 +1000)
committerMatt Joiner <anacrolix@gmail.com>
Wed, 25 Jun 2014 15:36:25 +0000 (01:36 +1000)
fs/torrentfs.go

index 7a00f28806a7bef86bbd3e8c77dd921dddb8b491..eb6c43f9f14e9eb30068ccdd051a6f22478a569e 100644 (file)
@@ -56,8 +56,8 @@ func (fn fileNode) Read(req *fuse.ReadRequest, resp *fuse.ReadResponse, intr fus
        if int64(fn.size)-req.Offset < int64(size) {
                size = int(int64(fn.size) - req.Offset)
        }
-       if size == 0 {
-               return nil
+       if size < 0 {
+               size = 0
        }
        infoHash := torrent.BytesInfoHash(fn.metaInfo.InfoHash)
        torrentOff := fn.TorrentOffset + req.Offset