From 9f755671fb6f8250da9c16a9abebbf975b8bc571 Mon Sep 17 00:00:00 2001 From: qwx Date: Tue, 8 Jan 2019 13:22:09 +0100 Subject: [PATCH] torrent: avoid trying to fetch blocks past file --- sys/src/cmd/ip/torrent.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sys/src/cmd/ip/torrent.c b/sys/src/cmd/ip/torrent.c index 5ce321b4c..01470712f 100644 --- a/sys/src/cmd/ip/torrent.c +++ b/sys/src/cmd/ip/torrent.c @@ -811,7 +811,8 @@ Error: } } } - havepiece(off / blocksize, w->str); + if(off < f->off + f->len) + havepiece(off / blocksize, w->str); havepiece(f->off / blocksize, w->str); close(fd); exits(0);