From c509f0b1eae93948111797a467ca3b5e6fac9c31 Mon Sep 17 00:00:00 2001
From: Matt Joiner <anacrolix@gmail.com>
Date: Thu, 26 Jun 2014 01:36:25 +1000
Subject: [PATCH] torrentfs: Reading an offset past the end of a file caused
 out of bounds panic

---
 fs/torrentfs.go | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/torrentfs.go b/fs/torrentfs.go
index 7a00f288..eb6c43f9 100644
--- a/fs/torrentfs.go
+++ b/fs/torrentfs.go
@@ -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
-- 
2.51.0