Expose 'bdecode limits' settings

This includes:
* Bdecode depth limit
* Bdecode token limit
This commit is contained in:
Chocobo1
2023-07-04 01:30:54 +08:00
parent 66dfe8545d
commit 5a660fc8a9
12 changed files with 98 additions and 13 deletions

View File

@@ -46,7 +46,6 @@
#include "base/utils/fs.h"
#include "base/utils/io.h"
#include "base/utils/misc.h"
#include "common.h"
#include "infohash.h"
#include "trackerentry.h"
@@ -87,9 +86,11 @@ nonstd::expected<TorrentInfo, QString> TorrentInfo::load(const QByteArray &data)
{
// 2-step construction to overcome default limits of `depth_limit` & `token_limit` which are
// used in `torrent_info()` constructor
const auto *pref = Preferences::instance();
lt::error_code ec;
const lt::bdecode_node node = lt::bdecode(data, ec
, nullptr, BENCODE_DEPTH_LIMIT, BENCODE_TOKEN_LIMIT);
, nullptr, pref->getBdecodeDepthLimit(), pref->getBdecodeTokenLimit());
if (ec)
return nonstd::make_unexpected(QString::fromStdString(ec.message()));