anacrolix / torrent

Full-featured BitTorrent client package and utilities
Mozilla Public License 2.0
5.39k stars 615 forks source link

don't return error when trying to read past EOF #860

Closed frrad closed 10 months ago

frrad commented 10 months ago

I encountered a bug where when an application attempts to read "across" the EOF (i.e. try to read $x$ bytes starting at offset $y$ where $x+y > len(file)$ ). The application dies with "unexpected EOF".

This patch fixes the bug for me.

I suspect that the fuse library does not expect Read to return non-nil errors except when no data was able to be read, but wasn't able to get into that library enough to confirm.

anacrolix commented 10 months ago

Do you have more context for your change @frrad ?

frrad commented 10 months ago

whoops! updated

anacrolix commented 10 months ago

Bummer. That violates Go's contract here, but should really be fixed in the fuse wrapper. The tests are passing so let's go with it. The fuse wrapper is at https://github.com/anacrolix/fuse if you wanted to try to find it.