From 0b2682659085486bad9c3be545e3e8d00c8b49f1 Mon Sep 17 00:00:00 2001 From: dengzhongyuan Date: Fri, 27 Feb 2026 10:57:45 +0800 Subject: [PATCH] fix: Improve argument handling in QProcess commands - Updated the command execution in DeviceInfo to use QStringList for better argument handling. - Enhanced the condition checks in HttpDriverInterface for OS build string length. - Refactored the rules file path construction in ControlInterface to use sanitized VID and PID. Log: Refactor command execution and improve string handling across multiple files. --- .../deepin-devicecontrol/src/controlinterface.cpp | 2 +- .../src/enablecontrol/enablesqlmanager.cpp | 2 +- deepin-devicemanager/src/DeviceManager/DeviceInfo.cpp | 2 +- .../src/DriverControl/HttpDriverInterface.cpp | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/deepin-devicemanager-server/deepin-devicecontrol/src/controlinterface.cpp b/deepin-devicemanager-server/deepin-devicecontrol/src/controlinterface.cpp index 33d00da3..ea1e1eee 100644 --- a/deepin-devicemanager-server/deepin-devicecontrol/src/controlinterface.cpp +++ b/deepin-devicemanager-server/deepin-devicecontrol/src/controlinterface.cpp @@ -222,7 +222,7 @@ bool ControlInterface::enableKeyboard(const QString& vid, const QString& pid, co return false; } - QString rulesFile = QString(UDEV_RULES_PATH_LOCAL "/99-keyboard-device-control-%1-%2.rules").arg(vid).arg(pid); + QString rulesFile = QString(UDEV_RULES_PATH_LOCAL "/99-keyboard-device-control-%1-%2.rules").arg(safeVid).arg(safePid); QString ruleContent; if (enable_device) { diff --git a/deepin-devicemanager-server/deepin-devicecontrol/src/enablecontrol/enablesqlmanager.cpp b/deepin-devicemanager-server/deepin-devicecontrol/src/enablecontrol/enablesqlmanager.cpp index 3bdcaca7..42bdee80 100644 --- a/deepin-devicemanager-server/deepin-devicecontrol/src/enablecontrol/enablesqlmanager.cpp +++ b/deepin-devicemanager-server/deepin-devicecontrol/src/enablecontrol/enablesqlmanager.cpp @@ -153,7 +153,7 @@ bool EnableSqlManager::uniqueIDExistedEX(const QString &key, const QString path) bool EnableSqlManager::isUniqueIdEnabled(const QString &key) { qCDebug(appLog) << "Checking if unique ID is enabled:" << key; - QString sql = QString("SELECT enable FROM %1 WHERE unique_id='%2';").arg(DB_TABLE_AUTHORIZED).arg(":key"); + QString sql = QString("SELECT enable FROM %1 WHERE unique_id=:key;").arg(DB_TABLE_AUTHORIZED); if(!m_sqlQuery.prepare(sql)) return false; m_sqlQuery.bindValue(":key", QVariant(key)); if (m_sqlQuery.exec() && m_sqlQuery.next()) { diff --git a/deepin-devicemanager/src/DeviceManager/DeviceInfo.cpp b/deepin-devicemanager/src/DeviceManager/DeviceInfo.cpp index 40d6f2d6..dc31cdc1 100644 --- a/deepin-devicemanager/src/DeviceManager/DeviceInfo.cpp +++ b/deepin-devicemanager/src/DeviceManager/DeviceInfo.cpp @@ -791,7 +791,7 @@ void DeviceBaseInfo::setVendorNameBylsusbLspci(const QString &vidpid, const QStr QProcess process; QString vendorId = vidpid.toLower().remove("0x").trimmed().left(4); QString deviceId = vidpid.toLower().remove("0x").trimmed().right(4); - process.start("lsusb -v -d " + vendorId + ":" + deviceId); + process.start("lsusb", QStringList() << "-v" << "-d" << QString("%1:%2").arg(vendorId, deviceId)); process.waitForFinished(-1); QString output = process.readAllStandardOutput(); diff --git a/deepin-devicemanager/src/DriverControl/HttpDriverInterface.cpp b/deepin-devicemanager/src/DriverControl/HttpDriverInterface.cpp index 0e5434ab..218a2200 100644 --- a/deepin-devicemanager/src/DriverControl/HttpDriverInterface.cpp +++ b/deepin-devicemanager/src/DriverControl/HttpDriverInterface.cpp @@ -115,7 +115,7 @@ QString HttpDriverInterface::getRequestBoard(QString strManufacturer, QString st if (!build.isEmpty()) { qCDebug(appLog) << "OS build is not empty, adding to URL"; QString system = build; - if (build[1] == "1") //专业版通过【产品线类型-产品线版本】方式进行系统构建匹配 + if (build.length() > 3 && build[1] == '1') //专业版通过【产品线类型-产品线版本】方式进行系统构建匹配 system = QString("%1-%2").arg(build[1]).arg(build[3]); strUrl += "&system=" + system; } @@ -127,7 +127,7 @@ QString HttpDriverInterface::getRequestBoard(QString strManufacturer, QString st qCDebug(appLog) << "OS build is not empty, adding to URL"; QString system = build; - if (build[1] == "1") //专业版通过【产品线类型-产品线版本】方式进行系统构建匹配 + if (build.length() > 3 && build[1] == '1') //专业版通过【产品线类型-产品线版本】方式进行系统构建匹配 system = QString("%1-%2").arg(build[1]).arg(build[3]); strUrl += "&system=" + system;