From: Matt Joiner Date: Mon, 12 Sep 2016 06:54:43 +0000 (+1000) Subject: Fix issue #112 X-Git-Tag: v1.0.0~589 X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=4d10fd3496e2accb759e1bab44b7e28011e5d284;p=btrtrc.git Fix issue #112 --- 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 }