Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix invalid argument error in stdin mode #341

Merged
merged 5 commits into from
Sep 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions src/controller/controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,15 +101,6 @@ void Controller::run()

startCommandExecution();

} catch (const std::invalid_argument& exc) {
if (isInStdinMode) {
// Pass invalid argument message to the caller just in case it may be interested
// The result will be {"invalid-argument" : message}
// Command parameter is only used if exception will be raised during json creation
writeResponseToStdOut(isInStdinMode, {{QStringLiteral("invalid-argument"), exc.what()}},
"invalid-argument");
}
onCriticalFailure(exc.what());
} catch (const std::exception& error) {
onCriticalFailure(error.what());
}
Expand Down
22 changes: 6 additions & 16 deletions src/ui/webeiddialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
* SOFTWARE.
*/

#include "utils/erasedata.hpp"

#include "webeiddialog.hpp"
#include "application.hpp"
#include "punycode.hpp"
Expand Down Expand Up @@ -292,7 +290,8 @@ QString WebEidDialog::getPin()
// QString uses QAtomicPointer internally and is thread-safe.
// There should be only single reference and this is transferred to the caller for safety
QString ret = pin;
eraseData(pin);
// Cannot use eraseData because we have to force Qt copy-on-write
pin.fill('\0');
pin.clear();
return ret;
}
Expand Down Expand Up @@ -464,7 +463,6 @@ void WebEidDialog::onVerifyPinFailed(const VerifyPinFailed::Status status, const
break;
case Status::PIN_BLOCKED:
displayPinBlockedError();
resizeHeight();
return;
case Status::INVALID_PIN_LENGTH:
message = [] { return tr("Invalid PIN length"); };
Expand All @@ -481,7 +479,7 @@ void WebEidDialog::onVerifyPinFailed(const VerifyPinFailed::Status status, const
case Status::UNKNOWN_ERROR:
message = [] { return tr("Technical error"); };
displayFatalError(message);
break;
return;
}

ui->pinErrorLabel->setVisible(bool(message));
Expand Down Expand Up @@ -681,17 +679,7 @@ void WebEidDialog::setupOK(Func func, const char* text, bool enabled)

void WebEidDialog::displayPinBlockedError()
{
ui->pinTitleLabel->hide();
ui->pinInput->hide();
ui->pinTimeoutTimer->stop();
ui->pinTimeRemaining->hide();
ui->pinEntryTimeoutProgressBar->hide();
setTrText(ui->pinErrorLabel, QT_TR_NOOP("PIN is locked. Unblock and try again."));
ui->pinErrorLabel->show();
ui->okButton->hide();
ui->cancelButton->setEnabled(true);
ui->cancelButton->show();
ui->helpButton->show();
displayFatalError([] { return tr("PIN is locked. Unblock and try again."); });
}

void WebEidDialog::displayFatalError(std::function<QString()> message)
Expand All @@ -706,6 +694,8 @@ void WebEidDialog::displayFatalError(std::function<QString()> message)
ui->okButton->hide();
ui->cancelButton->setEnabled(true);
ui->cancelButton->show();
ui->helpButton->show();
resizeHeight();
}

void WebEidDialog::showPinInputWarning(bool show)
Expand Down
Loading