From 4d10fd3496e2accb759e1bab44b7e28011e5d284 Mon Sep 17 00:00:00 2001 From: Matt Joiner Date: Mon, 12 Sep 2016 16:54:43 +1000 Subject: [PATCH] Fix issue #112 --- misc.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/misc.go b/misc.go index 42a65fe7..a9b024ec 100644 --- a/misc.go +++ b/misc.go @@ -62,8 +62,14 @@ func validateInfo(info *metainfo.Info) error { if len(info.Pieces)%20 != 0 { return errors.New("pieces has invalid length") } - if int((info.TotalLength()+info.PieceLength-1)/info.PieceLength) != info.NumPieces() { - return errors.New("piece count and file lengths are at odds") + if info.PieceLength == 0 { + if info.TotalLength() != 0 { + return errors.New("zero piece length") + } + } else { + if int((info.TotalLength()+info.PieceLength-1)/info.PieceLength) != info.NumPieces() { + return errors.New("piece count and file lengths are at odds") + } } return nil } -- 2.44.0