misc.go | 10 ++++++++-- diff --git a/misc.go b/misc.go index 42a65fe7d27314fec3244c225d3be85f23334951..a9b024ec4c7f9a2cccfb39dd25bf8f68d277e5e9 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 }