Commit a1cf31fa authored by Jonas Knarbakk's avatar Jonas Knarbakk Committed by Aleix Pol Gonzalez
Browse files

fix integer overflow in backends

parent 30555031
Pipeline #131216 passed with stage
in 52 seconds
......@@ -65,7 +65,7 @@ QString DummyResource::comment()
return QStringLiteral("A reasonably short comment ") + name();
}
int DummyResource::size()
quint64 DummyResource::size()
{
return m_size;
}
......
......@@ -23,7 +23,7 @@ public:
QString availableVersion() const override;
QString installedVersion() const override;
QJsonArray licenses() override;
int size() override;
quint64 size() override;
QUrl homepage() override;
QUrl helpURL() override;
QUrl bugURL() override;
......@@ -51,7 +51,7 @@ public:
return QStringLiteral("BananaPerson");
}
void setState(State state);
void setSize(int size)
void setSize(quint64 size)
{
m_size = size;
}
......@@ -75,7 +75,7 @@ public:
QString m_iconName;
QList<PackageState> m_addons;
const AbstractResource::Type m_type;
int m_size;
quint64 m_size;
};
#endif // DUMMYRESOURCE_H
......@@ -177,7 +177,7 @@ QString FlatpakResource::commit() const
return m_commit;
}
int FlatpakResource::downloadSize() const
quint64 FlatpakResource::downloadSize() const
{
return m_downloadSize;
}
......@@ -239,7 +239,7 @@ QString FlatpakResource::installedVersion() const
return version;
}
int FlatpakResource::installedSize() const
quint64 FlatpakResource::installedSize() const
{
return m_installedSize;
}
......@@ -365,7 +365,7 @@ QString FlatpakResource::section()
return QString();
}
int FlatpakResource::size()
quint64 FlatpakResource::size()
{
if (m_state == Installed) {
return m_installedSize;
......@@ -480,7 +480,7 @@ void FlatpakResource::setCommit(const QString &commit)
m_commit = commit;
}
void FlatpakResource::setDownloadSize(int size)
void FlatpakResource::setDownloadSize(quint64 size)
{
m_downloadSize = size;
......@@ -504,7 +504,7 @@ void FlatpakResource::setIconPath(const QString &path)
m_iconPath = path;
}
void FlatpakResource::setInstalledSize(int size)
void FlatpakResource::setInstalledSize(quint64 size)
{
m_installedSize = size;
......
......@@ -95,10 +95,10 @@ public:
QStringList categories() override;
QString comment() override;
QString commit() const;
int downloadSize() const;
quint64 downloadSize() const;
QVariant icon() const override;
QString installedVersion() const override;
int installedSize() const;
quint64 installedSize() const;
AbstractResource::Type type() const override;
QUrl homepage() override;
QUrl helpURL() override;
......@@ -115,7 +115,7 @@ public:
QUrl resourceFile() const;
QString runtime() const;
QString section() override;
int size() override;
quint64 size() override;
QString sizeDescription() override;
AbstractResource::State state() override;
ResourceType resourceType() const;
......@@ -140,9 +140,9 @@ public:
void setBranch(const QString &branch);
void setBundledIcon(const QPixmap &pixmap);
void setDownloadSize(int size);
void setDownloadSize(quint64 size);
void setIconPath(const QString &path);
void setInstalledSize(int size);
void setInstalledSize(quint64 size);
void setFlatpakFileType(FlatpakFileType fileType);
void setFlatpakName(const QString &name);
void setOrigin(const QString &origin);
......@@ -179,11 +179,11 @@ private:
FlatpakRefKind m_flatpakRefKind;
QPixmap m_bundledIcon;
QString m_commit;
int m_downloadSize;
qint64 m_downloadSize;
FlatpakFileType m_flatpakFileType = FlatpakResource::NotAFile;
QString m_flatpakName;
QString m_iconPath;
int m_installedSize;
qint64 m_installedSize;
QHash<PropertyKind, PropertyState> m_propertyStates;
QUrl m_resourceFile;
QUrl m_resourceLocation;
......
......@@ -45,7 +45,7 @@ QString FwupdResource::comment()
return m_summary;
}
int FwupdResource::size()
quint64 FwupdResource::size()
{
return m_size;
}
......
......@@ -30,7 +30,7 @@ public:
QString availableVersion() const override;
QString installedVersion() const override;
QJsonArray licenses() override;
int size() override;
quint64 size() override;
QUrl homepage() override;
QUrl helpURL() override;
QUrl bugURL() override;
......@@ -138,7 +138,7 @@ private:
AbstractResource::State m_state = None;
QUrl m_homepage;
QString m_iconName;
int m_size = 0;
quint64 m_size = 0;
QString m_updateURI;
bool m_isDeviceLocked = false; // True if device is locked!
......
......@@ -134,7 +134,7 @@ QJsonArray KNSResource::licenses()
return {QJsonObject{{QStringLiteral("name"), m_entry.license()}, {QStringLiteral("url"), QString()}}};
}
int KNSResource::size()
quint64 KNSResource::size()
{
const auto downloadInfo = m_entry.downloadLinkInformationList();
return downloadInfo.isEmpty() ? 0 : downloadInfo.at(0).size * 1024;
......
......@@ -40,7 +40,7 @@ public:
QString origin() const override;
QString section() override;
void fetchScreenshots() override;
int size() override;
quint64 size() override;
void fetchChangelog() override;
QStringList extends() const override;
AbstractResource::Type type() const override
......
......@@ -19,7 +19,7 @@ LocalFilePKResource::LocalFilePKResource(QUrl path, PackageKitBackend *parent)
{
}
int LocalFilePKResource::size()
quint64 LocalFilePKResource::size()
{
const QFileInfo info(m_path.toLocalFile());
return info.size();
......
......@@ -22,7 +22,7 @@ public:
{
return m_state;
}
int size() override;
quint64 size() override;
QString origin() const override;
void fetchDetails() override;
bool canExecute() const override
......
......@@ -115,7 +115,7 @@ QString PackageKitResource::installedVersion() const
return PackageKit::Daemon::packageVersion(installedPackageId());
}
int PackageKitResource::size()
quint64 PackageKitResource::size()
{
fetchDetails();
return m_details.size();
......
......@@ -30,7 +30,7 @@ public:
QString origin() const override;
QString section() override;
AbstractResource::Type type() const override;
int size() override;
quint64 size() override;
void fetchChangelog() override;
void fetchUpdateDetails() override;
......
......@@ -122,9 +122,9 @@ public:
return ret;
}
int size() override
quint64 size() override
{
int ret = 0;
quint64 ret = 0;
const auto resources = withoutDuplicates();
for (auto res : resources) {
ret += res->size();
......
......@@ -298,7 +298,7 @@ QString RpmOstreeResource::comment()
return i18n("Installed but not currently running version of %1.", packageName());
}
int RpmOstreeResource::size()
quint64 RpmOstreeResource::size()
{
return 0;
}
......
......@@ -34,7 +34,7 @@ public:
QString origin() const override;
QString section() override;
void fetchScreenshots() override {};
int size() override;
quint64 size() override;
void fetchChangelog() override {};
QStringList extends() const override;
AbstractResource::Type type() const override;
......
......@@ -95,7 +95,7 @@ QString SnapResource::comment()
return m_snap->summary();
}
int SnapResource::size()
quint64 SnapResource::size()
{
// return isInstalled() ? m_snap->installedSize() : m_snap->downloadSize();
return m_snap->downloadSize();
......
......@@ -31,7 +31,7 @@ public:
QString availableVersion() const override;
QString installedVersion() const override;
QJsonArray licenses() override;
int size() override;
quint64 size() override;
QStringList categories() override;
AbstractResource::State state() override;
QVariant icon() const override;
......
......@@ -53,7 +53,7 @@ class DISCOVERCOMMON_EXPORT AbstractResource : public QObject
Q_PROPERTY(QString longDescription READ longDescription NOTIFY longDescriptionChanged)
Q_PROPERTY(QString origin READ origin CONSTANT)
Q_PROPERTY(QString displayOrigin READ displayOrigin CONSTANT)
Q_PROPERTY(int size READ size NOTIFY sizeChanged)
Q_PROPERTY(quint64 size READ size NOTIFY sizeChanged)
Q_PROPERTY(QString sizeDescription READ sizeDescription NOTIFY sizeChanged)
Q_PROPERTY(QString installedVersion READ installedVersion NOTIFY versionsChanged)
Q_PROPERTY(QString availableVersion READ availableVersion NOTIFY versionsChanged)
......@@ -140,7 +140,7 @@ public:
Q_ENUM(Type);
virtual Type type() const = 0;
virtual int size() = 0;
virtual quint64 size() = 0;
virtual QString sizeDescription();
///@returns a list of pairs with the name of the license and a URL pointing at it
......
Supports Markdown
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