git: 9front

Download patch

ref: 47b8e00e1eb9bbcad71ff8a090518cad717da31f
parent: 19a7f623370f4474e55b2462cb7ba5e647843908
author: cinap_lenrek <cinap_lenrek@gmx.de>
date: Tue Oct 8 04:12:05 EDT 2013

ip/torrent: check piece offset, vlong cast

--- a/sys/src/cmd/ip/torrent.c
+++ b/sys/src/cmd/ip/torrent.c
@@ -192,11 +192,11 @@
 	int n, m;
 	File *f;
 
-	if(len <= 0 || poff >= pieces[index].len)
+	if(len <= 0 || poff < 0 || poff >= pieces[index].len)
 		return 0;
 	if(len+poff > pieces[index].len)
 		len = pieces[index].len - poff;
-	off = (vlong)index * blocksize;
+	off = (vlong)index * (vlong)blocksize;
 	off += poff;
 	for(f = files; f; f = f->next)
 		if((f->off+f->len) > off)
--