Verified Commit ef43ebc8 authored by Melvin Vermeeren's avatar Melvin Vermeeren 🍉
Browse files

raise peer max metasize (torrent file) size to 100mib

Perhaps the 4MiB metadata limit made sense when it was introduced years
ago, but with modern storage devices easily being over 10TB more and
more 1TB+ torrents can be found in the wild. These torrent files
(metadata) are easily over 4MiB.

This patch raises the limit to 100MiB. Raising the limit in the end only
delays the problem for a few decades or so, as storage density only
keeps increasing and files keep growing in size. A more permanent
solution without arbitrary limits would be ideal.

Fixes https://bugs.kde.org/show_bug.cgi?id=392202, where the reporter
mentions Touhou Lossless Music Collection, which is a ~9MiB torrent for
version 19 of the main part of the collection.

Check initially introduced in c743f5e1.
parent 70586966
......@@ -46,7 +46,7 @@ using namespace net;
namespace bt
{
static const int MAX_METADATA_SIZE = 4 * 1024 * 1024; // maximum allowed metadata_size (up to 4 MiB)
static const int MAX_METADATA_SIZE = 100 * 1024 * 1024; // maximum allowed metadata_size (up to 100 MiB)
static Uint32 peer_id_counter = 1;
bool Peer::resolve_hostname = true;
......@@ -453,7 +453,8 @@ void Peer::handleExtendedHandshake(const Uint8* packet, Uint32 size)
metadata_size = dict->getInt(QByteArrayLiteral("metadata_size"));
if (metadata_size > MAX_METADATA_SIZE) { // check for wrong metadata_size values
Out(SYS_GEN | LOG_NOTICE) << "Wrong metadata size: " << metadata_size << ". Killing peer... " << endl;
Out(SYS_GEN | LOG_NOTICE) << "Wrong or too high metadata size: " << metadata_size << ". Killing peer... " << endl;
Out(SYS_GEN | LOG_NOTICE) << "Maximum supported metadata (torrent file) size: " << MAX_METADATA_SIZE << endl;
kill();
delete node;
return;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment