mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-07-06 13:11:25 -07:00
parent
4497ca4a0e
commit
6ee6815d24
6 changed files with 20 additions and 13 deletions
|
@ -48,6 +48,7 @@
|
|||
#include "base/utils/fs.h"
|
||||
#include "base/utils/io.h"
|
||||
#include "base/utils/string.h"
|
||||
#include "common.h"
|
||||
#include "infohash.h"
|
||||
#include "loadtorrentparams.h"
|
||||
|
||||
|
@ -196,7 +197,8 @@ void BitTorrent::BencodeResumeDataStorage::loadQueue(const Path &queueFilename)
|
|||
BitTorrent::LoadResumeDataResult BitTorrent::BencodeResumeDataStorage::loadTorrentResumeData(const QByteArray &data, const QByteArray &metadata) const
|
||||
{
|
||||
lt::error_code ec;
|
||||
const lt::bdecode_node resumeDataRoot = lt::bdecode(data, ec);
|
||||
const lt::bdecode_node resumeDataRoot = lt::bdecode(data, ec
|
||||
, nullptr, BENCODE_DEPTH_LIMIT, BENCODE_TOKEN_LIMIT);
|
||||
if (ec)
|
||||
return nonstd::make_unexpected(tr("Cannot parse resume data: %1").arg(QString::fromStdString(ec.message())));
|
||||
|
||||
|
@ -263,7 +265,8 @@ BitTorrent::LoadResumeDataResult BitTorrent::BencodeResumeDataStorage::loadTorre
|
|||
|
||||
if (!metadata.isEmpty())
|
||||
{
|
||||
const lt::bdecode_node torentInfoRoot = lt::bdecode(metadata, ec);
|
||||
const lt::bdecode_node torentInfoRoot = lt::bdecode(metadata, ec
|
||||
, nullptr, BENCODE_DEPTH_LIMIT, BENCODE_TOKEN_LIMIT);
|
||||
if (ec)
|
||||
return nonstd::make_unexpected(tr("Cannot parse torrent info: %1").arg(QString::fromStdString(ec.message())));
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Bittorrent Client using Qt and libtorrent.
|
||||
* Copyright (C) 2020 Vladimir Golovnev <glassez@yandex.ru>
|
||||
* Copyright (C) 2020-2023 Vladimir Golovnev <glassez@yandex.ru>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -33,3 +33,7 @@
|
|||
#include "base/global.h"
|
||||
|
||||
inline const QString QB_EXT = u".!qB"_qs;
|
||||
|
||||
inline const int MAX_TORRENT_SIZE = 100 * 1024 * 1024; // 100 MiB
|
||||
inline const int BENCODE_DEPTH_LIMIT = 100;
|
||||
inline const int BENCODE_TOKEN_LIMIT = 10'000'000;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Bittorrent Client using Qt and libtorrent.
|
||||
* Copyright (C) 2021-2022 Vladimir Golovnev <glassez@yandex.ru>
|
||||
* Copyright (C) 2021-2023 Vladimir Golovnev <glassez@yandex.ru>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -54,6 +54,7 @@
|
|||
#include "base/profile.h"
|
||||
#include "base/utils/fs.h"
|
||||
#include "base/utils/string.h"
|
||||
#include "common.h"
|
||||
#include "infohash.h"
|
||||
#include "loadtorrentparams.h"
|
||||
|
||||
|
@ -228,7 +229,8 @@ namespace BitTorrent
|
|||
const QByteArray bencodedResumeData = query.value(DB_COLUMN_RESUMEDATA.name).toByteArray();
|
||||
|
||||
lt::error_code ec;
|
||||
const lt::bdecode_node resumeDataRoot = lt::bdecode(bencodedResumeData, ec);
|
||||
const lt::bdecode_node resumeDataRoot = lt::bdecode(bencodedResumeData, ec
|
||||
, nullptr, BENCODE_DEPTH_LIMIT, BENCODE_TOKEN_LIMIT);
|
||||
|
||||
lt::add_torrent_params &p = resumeData.ltAddTorrentParams;
|
||||
|
||||
|
@ -236,7 +238,8 @@ namespace BitTorrent
|
|||
|
||||
if (const QByteArray bencodedMetadata = query.value(DB_COLUMN_METADATA.name).toByteArray(); !bencodedMetadata.isEmpty())
|
||||
{
|
||||
const lt::bdecode_node torentInfoRoot = lt::bdecode(bencodedMetadata, ec);
|
||||
const lt::bdecode_node torentInfoRoot = lt::bdecode(bencodedMetadata, ec
|
||||
, nullptr, BENCODE_DEPTH_LIMIT, BENCODE_TOKEN_LIMIT);
|
||||
p.ti = std::make_shared<lt::torrent_info>(torentInfoRoot, ec);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Bittorrent Client using Qt and libtorrent.
|
||||
* Copyright (C) 2015 Vladimir Golovnev <glassez@yandex.ru>
|
||||
* Copyright (C) 2015-2023 Vladimir Golovnev <glassez@yandex.ru>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -45,6 +45,7 @@
|
|||
#include "base/utils/fs.h"
|
||||
#include "base/utils/io.h"
|
||||
#include "base/utils/misc.h"
|
||||
#include "common.h"
|
||||
#include "infohash.h"
|
||||
#include "trackerentry.h"
|
||||
|
||||
|
@ -91,12 +92,9 @@ 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 int depthLimit = 100;
|
||||
const int tokenLimit = 10000000;
|
||||
|
||||
lt::error_code ec;
|
||||
const lt::bdecode_node node = lt::bdecode(data, ec
|
||||
, nullptr, depthLimit, tokenLimit);
|
||||
, nullptr, BENCODE_DEPTH_LIMIT, BENCODE_TOKEN_LIMIT);
|
||||
if (ec)
|
||||
return nonstd::make_unexpected(QString::fromStdString(ec.message()));
|
||||
|
||||
|
|
|
@ -35,8 +35,6 @@
|
|||
#define QBT_APP_64BIT
|
||||
#endif
|
||||
|
||||
inline const int MAX_TORRENT_SIZE = 100 * 1024 * 1024; // 100 MiB
|
||||
|
||||
template <typename T>
|
||||
constexpr typename std::add_const_t<T> &asConst(T &t) noexcept { return t; }
|
||||
|
||||
|
|
|
@ -41,6 +41,7 @@
|
|||
#include <QUrl>
|
||||
#include <QVector>
|
||||
|
||||
#include "base/bittorrent/common.h"
|
||||
#include "base/bittorrent/downloadpriority.h"
|
||||
#include "base/bittorrent/infohash.h"
|
||||
#include "base/bittorrent/magneturi.h"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue