mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-12-31 20:58:07 -06:00
Don't read unlimited data from files
It now guards against reading infinite files such as `/dev/zero`. And most readings are bound with a (lax) limit. As a side effect, more checking are done when reading a file and overall the reading procedure is more robust. PR #19095.
This commit is contained in:
@@ -36,6 +36,7 @@
|
||||
#include <QDomDocument>
|
||||
#include <QDomElement>
|
||||
#include <QDomNode>
|
||||
#include <QFile>
|
||||
#include <QPointer>
|
||||
#include <QProcess>
|
||||
#include <QUrl>
|
||||
@@ -517,7 +518,7 @@ void SearchPluginManager::update()
|
||||
nova.start(Utils::ForeignApps::pythonInfo().executableName, params, QIODevice::ReadOnly);
|
||||
nova.waitForFinished();
|
||||
|
||||
const auto capabilities = QString::fromUtf8(nova.readAll());
|
||||
const auto capabilities = QString::fromUtf8(nova.readAllStandardOutput());
|
||||
QDomDocument xmlDoc;
|
||||
if (!xmlDoc.setContent(capabilities))
|
||||
{
|
||||
@@ -629,13 +630,15 @@ Path SearchPluginManager::pluginPath(const QString &name)
|
||||
|
||||
PluginVersion SearchPluginManager::getPluginVersion(const Path &filePath)
|
||||
{
|
||||
const int lineMaxLength = 16;
|
||||
|
||||
QFile pluginFile {filePath.data()};
|
||||
if (!pluginFile.open(QIODevice::ReadOnly | QIODevice::Text))
|
||||
return {};
|
||||
|
||||
while (!pluginFile.atEnd())
|
||||
{
|
||||
const auto line = QString::fromUtf8(pluginFile.readLine()).remove(u' ');
|
||||
const auto line = QString::fromUtf8(pluginFile.readLine(lineMaxLength)).remove(u' ');
|
||||
if (!line.startsWith(u"#VERSION:", Qt::CaseInsensitive)) continue;
|
||||
|
||||
const QString versionStr = line.mid(9);
|
||||
|
||||
Reference in New Issue
Block a user