commit 3bbc9320e8c90fafe2f60e7fe9dc2cb967a5f0b0
parent 5962df9a75514a370e16e12d9311a3d2ff3c2037
Author: sin <sin@2f30.org>
Date: Fri, 18 Dec 2015 16:23:26 +0000
Check if length is negative or zero
Diffstat:
1 file changed, 4 insertions(+), 0 deletions(-)
diff --git a/torrent.c b/torrent.c
@@ -100,6 +100,10 @@ loadtorrent(char *f)
goto err2;
}
t->length = dlookstr(t->info, "length")->i;
+ if (t->length <= 0) {
+ warnx("length is <= 0 in %s", f);
+ goto err2;
+ }
if (!dlookstr(t->info, "piece length")) {
warnx("no piece length field in %s", f);