From 978613a529e22f647a080e419f6a8a66fec68f3f Mon Sep 17 00:00:00 2001 From: lzwind lzwind Date: Mon, 3 Mar 2025 13:21:37 +0000 Subject: [PATCH] Return early when SSH config file cannot be opened When attempting to import SSH configurations, the code previously continued execution even when the config file could not be opened. This could lead to undefined behavior or crashes when trying to read from an invalid file handle. The fix adds an early return statement when file opening fails, ensuring proper error handling and preventing potential issues downstream. (cherry picked from commit 70452321ceb1165f4626f53148fed12841692a50) --- src/plugins/SSHManager/sshmanagermodel.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/plugins/SSHManager/sshmanagermodel.cpp b/src/plugins/SSHManager/sshmanagermodel.cpp index 971a09c9f..82af8f434 100644 --- a/src/plugins/SSHManager/sshmanagermodel.cpp +++ b/src/plugins/SSHManager/sshmanagermodel.cpp @@ -332,6 +332,7 @@ void SSHManagerModel::importFromSshConfigFile(const QString &file) QFile sshConfig(file); if (!sshConfig.open(QIODevice::ReadOnly)) { qCDebug(SshManagerPluginDebug) << "Can't open config file"; + return; } QTextStream stream(&sshConfig); QString line;