aboutsummaryrefslogtreecommitdiffstats
path: root/src/core/function/gpg/GpgContext.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/function/gpg/GpgContext.cpp')
-rw-r--r--src/core/function/gpg/GpgContext.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/core/function/gpg/GpgContext.cpp b/src/core/function/gpg/GpgContext.cpp
index a4757d7f..2d9c5992 100644
--- a/src/core/function/gpg/GpgContext.cpp
+++ b/src/core/function/gpg/GpgContext.cpp
@@ -110,7 +110,7 @@ class GpgContext::Impl {
}
res += gpgme_io_write(fd, "\n", 1);
- return res == pass_size + 1 ? 0 : gpgme_error_from_errno(GPG_ERR_CANCELED);
+ return res == pass_size + 1 ? 0 : GPG_ERR_CANCELED;
}
static auto CustomPassphraseCb(void *hook, const char *uid_hint,
@@ -143,13 +143,18 @@ class GpgContext::Impl {
[&passphrase, &looper](Module::EventIdentifier i,
Module::Event::ListenerIdentifier ei,
Module::Event::Params p) {
- passphrase = p["passphrase"];
+ if (p["ret"] == "0") passphrase = p["passphrase"];
looper.quit();
});
looper.exec();
ResetCacheValue("PinentryContext");
+ LOG_D() << "passphrase size:" << passphrase.size();
+
+ // empty passphrase is not allowed
+ if (passphrase.isEmpty()) return GPG_ERR_CANCELED;
+
auto pass_bytes = passphrase.toLatin1();
auto pass_size = pass_bytes.size();
const auto *p_pass_bytes = pass_bytes.constData();
@@ -166,7 +171,7 @@ class GpgContext::Impl {
}
res += gpgme_io_write(fd, "\n", 1);
- return res == pass_size + 1 ? 0 : gpgme_error_from_errno(GPG_ERR_CANCELED);
+ return res == pass_size + 1 ? 0 : GPG_ERR_CANCELED;
}
static auto TestStatusCb(void *hook, const char *keyword,