mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2026-11-22 22:28:03 +00:00
set malformed metaInfo error if parsing failed
This commit is contained in:
1 parent
00f3ea6691
commit
fadc607440
1 file changed
+8
-3
@@ -433,7 +433,7 @@ namespace torrents
|
||||
|
||||
Torrent::Torrent (std::string_view buf): Torrent ()
|
||||
{
|
||||
ParseDictionary (buf, [this](std::string_view key, std::string_view buf)->size_t
|
||||
if (!ParseDictionary (buf, [this](std::string_view key, std::string_view buf)->size_t
|
||||
{
|
||||
if (key == "announce")
|
||||
{
|
||||
@@ -444,7 +444,8 @@ namespace torrents
|
||||
else if (key == "info")
|
||||
return ParseInfo (buf);
|
||||
return 0;
|
||||
});
|
||||
}))
|
||||
m_Error = eTorrentErrorMalformedMetaInfo;
|
||||
}
|
||||
|
||||
Torrent::Torrent (const InfoHash& infoHash): Torrent ()
|
||||
@@ -539,7 +540,11 @@ namespace torrents
|
||||
return ParseFiles (buf);
|
||||
return 0;
|
||||
});
|
||||
if (!len) return 0;
|
||||
if (!len)
|
||||
{
|
||||
m_Error = eTorrentErrorMalformedMetaInfo;
|
||||
return 0;
|
||||
}
|
||||
if (m_IsSingleFile && !m_Name.empty ()) // single file
|
||||
m_Files.emplace_back (std::make_shared<TorrentFile> (m_Name, m_Length));
|
||||
// save info
|
||||
|
||||
Reference in new issue
Block a user