From 31a6ad1eb6d15da16f67ebf93f0e025e025103f9 Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Thu, 27 Jun 2019 20:29:02 +0800 Subject: [PATCH 1/4] Drop suspiciously large data This is to avoid exhausting system memory. --- src/app/qtsingleapplication/qtlocalpeer.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/app/qtsingleapplication/qtlocalpeer.cpp b/src/app/qtsingleapplication/qtlocalpeer.cpp index f3c4546b6..cb4c57492 100644 --- a/src/app/qtsingleapplication/qtlocalpeer.cpp +++ b/src/app/qtsingleapplication/qtlocalpeer.cpp @@ -191,6 +191,12 @@ void QtLocalPeer::receiveConnection() QByteArray uMsg; quint32 remaining; ds >> remaining; + if (remaining > 65535) { + // drop suspiciously large data + delete socket; + return; + } + uMsg.resize(remaining); int got = 0; char* uMsgBuf = uMsg.data(); From bad60058df06a98f22f5369609f2305e1e5f3421 Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Thu, 27 Jun 2019 20:33:05 +0800 Subject: [PATCH 2/4] Restrict QLocalServer access The default is world access which means even even unprivileged local accounts can connect to it too. --- src/app/qtsingleapplication/qtlocalpeer.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/app/qtsingleapplication/qtlocalpeer.cpp b/src/app/qtsingleapplication/qtlocalpeer.cpp index cb4c57492..d8a1bce31 100644 --- a/src/app/qtsingleapplication/qtlocalpeer.cpp +++ b/src/app/qtsingleapplication/qtlocalpeer.cpp @@ -101,6 +101,7 @@ QtLocalPeer::QtLocalPeer(QObject* parent, const QString &appId) #endif server = new QLocalServer(this); + server->setSocketOptions(QLocalServer::UserAccessOption); QString lockName = QDir(QDir::tempPath()).absolutePath() + QLatin1Char('/') + socketName + QLatin1String("-lockfile"); From 4ab32a76f6bd41e8725130116fa9a2f2794eb219 Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Sat, 29 Jun 2019 19:56:36 +0800 Subject: [PATCH 3/4] Fix torrent properties not saved for paused torrents --- src/base/bittorrent/torrenthandle.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/base/bittorrent/torrenthandle.cpp b/src/base/bittorrent/torrenthandle.cpp index 13842b61d..5d4667649 100644 --- a/src/base/bittorrent/torrenthandle.cpp +++ b/src/base/bittorrent/torrenthandle.cpp @@ -1285,6 +1285,8 @@ void TorrentHandle::setSequentialDownload(bool b) m_nativeHandle.set_sequential_download(b); m_nativeStatus.sequential_download = b; // prevent return cached value } + + saveResumeData(); } void TorrentHandle::toggleSequentialDownload() @@ -1331,6 +1333,8 @@ void TorrentHandle::setFirstLastPiecePriorityImpl(const bool enabled, const QVec LogMsg(tr("Download first and last piece first: %1, torrent: '%2'") .arg((enabled ? tr("On") : tr("Off")), name())); + + saveResumeData(); } void TorrentHandle::toggleFirstLastPiecePriority() From 3e9be3a0e8d8a42c12bb02ab8ecc4290cd05f09a Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Sun, 30 Jun 2019 20:39:49 +0800 Subject: [PATCH 4/4] Use proper log message when there are no error --- src/base/bittorrent/session.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/base/bittorrent/session.cpp b/src/base/bittorrent/session.cpp index 71694358d..0b6162f0b 100644 --- a/src/base/bittorrent/session.cpp +++ b/src/base/bittorrent/session.cpp @@ -4316,9 +4316,14 @@ void Session::handleTorrentDeleteFailedAlert(libt::torrent_delete_failed_alert * // so we remove the directory ourselves Utils::Fs::smartRemoveEmptyFolderTree(tmpRemovingTorrentData.savePathToRemove); - LogMsg(tr("'%1' was removed from the transfer list but the files couldn't be deleted. Error: %2", "'xxx.avi' was removed...") - .arg(tmpRemovingTorrentData.name, QString::fromLocal8Bit(p->error.message().c_str())) - , Log::CRITICAL); + if (p->error) { + LogMsg(tr("'%1' was removed from the transfer list but the files couldn't be deleted. Error: %2", "'xxx.avi' was removed...") + .arg(tmpRemovingTorrentData.name, QString::fromStdString(p->error.message())) + , Log::WARNING); + } + else { + LogMsg(tr("'%1' was removed from the transfer list.", "'xxx.avi' was removed...").arg(tmpRemovingTorrentData.name)); + } } void Session::handleMetadataReceivedAlert(libt::metadata_received_alert *p)