summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@gmx.de>2013-10-08 08:12:05 +0200
committercinap_lenrek <cinap_lenrek@gmx.de>2013-10-08 08:12:05 +0200
commit50e3c936fac64a1b4f0d89b909bceb4ed889f385 (patch)
tree182fa1790c59d1b7d7704665861a419638ba7d90
parent3c2b09c9dc9b3bb1b7177f7683002c86d38fcaa0 (diff)
downloadplan9front-50e3c936fac64a1b4f0d89b909bceb4ed889f385.tar.xz
ip/torrent: check piece offset, vlong cast
-rw-r--r--sys/src/cmd/ip/torrent.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/sys/src/cmd/ip/torrent.c b/sys/src/cmd/ip/torrent.c
index c8193d727..96d3d524a 100644
--- a/sys/src/cmd/ip/torrent.c
+++ b/sys/src/cmd/ip/torrent.c
@@ -192,11 +192,11 @@ rwpiece(int wr, int index, uchar *data, int len, int poff)
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)