aboutsummaryrefslogtreecommitdiffstats
path: root/src/core/function/gpg/GpgContext.cpp
diff options
context:
space:
mode:
authorsaturneric <[email protected]>2024-01-18 12:58:37 +0000
committersaturneric <[email protected]>2024-01-18 12:58:37 +0000
commite0d2c4021483e6e1366c1050ccb5a30e53e172bb (patch)
tree5d85739479622e7c672aea45f84d4e2f577f9332 /src/core/function/gpg/GpgContext.cpp
parentfix: correct a fault (diff)
downloadGpgFrontend-e0d2c4021483e6e1366c1050ccb5a30e53e172bb.tar.gz
GpgFrontend-e0d2c4021483e6e1366c1050ccb5a30e53e172bb.zip
fix: add test cases and solve discovered issues
Diffstat (limited to 'src/core/function/gpg/GpgContext.cpp')
-rw-r--r--src/core/function/gpg/GpgContext.cpp11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/core/function/gpg/GpgContext.cpp b/src/core/function/gpg/GpgContext.cpp
index 104e254f..6523386c 100644
--- a/src/core/function/gpg/GpgContext.cpp
+++ b/src/core/function/gpg/GpgContext.cpp
@@ -94,16 +94,19 @@ class GpgContext::Impl {
int fd) -> gpgme_error_t {
size_t res;
QString pass = "abcdefg\n";
- auto pass_len = pass.size();
+ auto passpahrase_size = pass.size();
size_t off = 0;
do {
- res = gpgme_io_write(fd, &pass[off], pass_len - off);
+ res = gpgme_io_write(fd, &pass[off], passpahrase_size - off);
if (res > 0) off += res;
- } while (res > 0 && off != pass_len);
+ } while (res > 0 && off != passpahrase_size);
- return off == pass_len ? 0 : gpgme_error_from_errno(errno);
+ res += gpgme_io_write(fd, "\n", 1);
+ return res == passpahrase_size + 1
+ ? 0
+ : gpgme_error_from_errno(GPG_ERR_CANCELED);
}
static auto CustomPassphraseCb(void *hook, const char *uid_hint,