From 4c250f8a5ddd73e2bb02d8573bc66432c1dca7b2 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Mon, 18 Sep 2023 11:00:00 +0900 Subject: Bail out if pieceLength is 0 --- src/DefaultBtProgressInfoFile.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/DefaultBtProgressInfoFile.cc b/src/DefaultBtProgressInfoFile.cc index 7a5da1c3..b2161828 100644 --- a/src/DefaultBtProgressInfoFile.cc +++ b/src/DefaultBtProgressInfoFile.cc @@ -289,6 +289,10 @@ void DefaultBtProgressInfoFile::load() pieceLength = ntohl(pieceLength); } + if (pieceLength == 0) { + throw DL_ABORT_EX("piece length must not be 0"); + } + uint64_t totalLength; READ_CHECK(fp, &totalLength, sizeof(totalLength)); if (version >= 1) { -- cgit