diff options
Diffstat (limited to 'src/ui/main_window/KeyMgmt.cpp')
-rw-r--r-- | src/ui/main_window/KeyMgmt.cpp | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/src/ui/main_window/KeyMgmt.cpp b/src/ui/main_window/KeyMgmt.cpp index c9353b90..67150d85 100644 --- a/src/ui/main_window/KeyMgmt.cpp +++ b/src/ui/main_window/KeyMgmt.cpp @@ -529,14 +529,33 @@ void KeyMgmt::SlotExportAsOpenSSHFormat() { void KeyMgmt::SlotImportKeyPackage() { auto key_package_file_name = QFileDialog::getOpenFileName( - this, tr("Import Key Package"), {}, - tr("Key Package") + " (*.gfepack);;All Files (*)"); + this, tr("Import Key Package"), {}, tr("Key Package") + " (*.gfepack)"); + + if (key_package_file_name.isEmpty()) return; + + // max file size is 32 mb + QFileInfo key_package_file_info(key_package_file_name); + if (key_package_file_info.size() > static_cast<qint64>(32 * 1024 * 1024)) { + QMessageBox::critical( + this, tr("Error"), + tr("The target file is too large for a key package.")); + return; + } auto key_file_name = QFileDialog::getOpenFileName( this, tr("Import Key Package Passphrase File"), {}, - tr("Key Package Passphrase File") + " (*.key);;All Files (*)"); + tr("Key Package Passphrase File") + " (*.key)"); - if (key_package_file_name.isEmpty() || key_file_name.isEmpty()) return; + if (key_file_name.isEmpty()) return; + + // max file size is 1 mb + QFileInfo key_file_info(key_file_name); + if (key_file_info.size() > static_cast<qint64>(1024 * 1024)) { + QMessageBox::critical( + this, tr("Error"), + tr("The target file is too large for a key package passphrase.")); + return; + } GF_UI_LOG_INFO("importing key package: {}", key_package_file_name); CommonUtils::WaitForOpera( |