Use std::find instead of iterating to search in allowedCommands.

This commit is contained in:
Caio Carvalho 2018-08-24 12:14:49 -03:00
parent f8cdf99606
commit 7853424a62
1 changed files with 3 additions and 8 deletions

View File

@ -288,16 +288,11 @@ QVariantMap ExternalCommandHelper::start(const QByteArray& signature, const quin
// Compare with command whitelist
QString basename = command.mid(command.lastIndexOf(QLatin1Char('/')) + 1);
bool success = false;
for (const auto& command : allowedCommands) {
if (basename == command) {
success = true;
break;
}
}
if ( !success ) {
if (std::find(std::begin(allowedCommands), std::end(allowedCommands), basename) == std::end(allowedCommands)) {
// TODO: notify the user
m_loop->exit();
reply[QStringLiteral("success")] = false;
return reply;
}
// connect(&cmd, &QProcess::readyReadStandardOutput, this, &ExternalCommandHelper::onReadOutput);