shithub: riscv

Download patch

ref: 50e3c936fac64a1b4f0d89b909bceb4ed889f385
parent: 3c2b09c9dc9b3bb1b7177f7683002c86d38fcaa0
author: cinap_lenrek <[email protected]>
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)