From ac3817ec84d083eae50588fb402e4db58cc7baa2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20Jos=C3=A9=20Pereira?= Date: Tue, 11 Jun 2024 11:44:37 -0300 Subject: [PATCH] sensor: ping: Add check to ignore invalid firmware files MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Patrick José Pereira --- src/sensor/ping.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/sensor/ping.cpp b/src/sensor/ping.cpp index cc1589fe6..3463822cd 100644 --- a/src/sensor/ping.cpp +++ b/src/sensor/ping.cpp @@ -513,6 +513,10 @@ void Ping::checkNewFirmwareInGitHubPayload(const QJsonDocument& jsonDocument) // Get version from Ping(\d|)[_|-]V(major).(patch)*.hex where (major).(patch) is static const QRegularExpression versionRegex(QStringLiteral(R"(Ping(\d|)[_|-]V(?\d+\.\d+).*\.hex)")); auto filePayloadVersion = versionRegex.match(filePayload["name"].toString()).captured("version").toFloat(); + if (filePayloadVersion <= 0) { + qCWarning(PING_PROTOCOL_PING) << "Invalid version:" << filePayload["name"].toString(); + continue; + } _firmwares[filePayload["name"].toString()] = filePayload["download_url"].toString(); if (filePayloadVersion > lastVersionAvailable) {