Skip to content

Commit b6d5eef

Browse files
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.
1 parent 22045ff commit b6d5eef

4 files changed

Lines changed: 5 additions & 5 deletions

File tree

deepin-devicemanager-server/deepin-devicecontrol/src/controlinterface.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ bool ControlInterface::enableKeyboard(const QString& vid, const QString& pid, co
222222
return false;
223223
}
224224

225-
QString rulesFile = QString(UDEV_RULES_PATH_LOCAL "/99-keyboard-device-control-%1-%2.rules").arg(vid).arg(pid);
225+
QString rulesFile = QString(UDEV_RULES_PATH_LOCAL "/99-keyboard-device-control-%1-%2.rules").arg(safeVid).arg(safePid);
226226

227227
QString ruleContent;
228228
if (enable_device) {

deepin-devicemanager-server/deepin-devicecontrol/src/enablecontrol/enablesqlmanager.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ bool EnableSqlManager::uniqueIDExistedEX(const QString &key, const QString path)
153153
bool EnableSqlManager::isUniqueIdEnabled(const QString &key)
154154
{
155155
qCDebug(appLog) << "Checking if unique ID is enabled:" << key;
156-
QString sql = QString("SELECT enable FROM %1 WHERE unique_id='%2';").arg(DB_TABLE_AUTHORIZED).arg(":key");
156+
QString sql = QString("SELECT enable FROM %1 WHERE unique_id=:key;").arg(DB_TABLE_AUTHORIZED);
157157
if(!m_sqlQuery.prepare(sql)) return false;
158158
m_sqlQuery.bindValue(":key", QVariant(key));
159159
if (m_sqlQuery.exec() && m_sqlQuery.next()) {

deepin-devicemanager/src/DeviceManager/DeviceInfo.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -791,7 +791,7 @@ void DeviceBaseInfo::setVendorNameBylsusbLspci(const QString &vidpid, const QStr
791791
QProcess process;
792792
QString vendorId = vidpid.toLower().remove("0x").trimmed().left(4);
793793
QString deviceId = vidpid.toLower().remove("0x").trimmed().right(4);
794-
process.start("lsusb -v -d " + vendorId + ":" + deviceId);
794+
process.start("lsusb", QStringList() << "-v" << "-d" << QString("%1:%2").arg(vendorId, deviceId));
795795
process.waitForFinished(-1);
796796

797797
QString output = process.readAllStandardOutput();

deepin-devicemanager/src/DriverControl/HttpDriverInterface.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ QString HttpDriverInterface::getRequestBoard(QString strManufacturer, QString st
115115
if (!build.isEmpty()) {
116116
qCDebug(appLog) << "OS build is not empty, adding to URL";
117117
QString system = build;
118-
if (build[1] == "1") //专业版通过【产品线类型-产品线版本】方式进行系统构建匹配
118+
if (build.length() > 3 && build[1] == '1') //专业版通过【产品线类型-产品线版本】方式进行系统构建匹配
119119
system = QString("%1-%2").arg(build[1]).arg(build[3]);
120120
strUrl += "&system=" + system;
121121
}
@@ -127,7 +127,7 @@ QString HttpDriverInterface::getRequestBoard(QString strManufacturer, QString st
127127
qCDebug(appLog) << "OS build is not empty, adding to URL";
128128
QString system = build;
129129

130-
if (build[1] == "1") //专业版通过【产品线类型-产品线版本】方式进行系统构建匹配
130+
if (build.length() > 3 && build[1] == '1') //专业版通过【产品线类型-产品线版本】方式进行系统构建匹配
131131
system = QString("%1-%2").arg(build[1]).arg(build[3]);
132132

133133
strUrl += "&system=" + system;

0 commit comments

Comments
 (0)