diff options
author | Ingo Klöcker <[email protected]> | 2024-08-28 14:32:18 +0000 |
---|---|---|
committer | Ingo Klöcker <[email protected]> | 2024-08-28 14:32:18 +0000 |
commit | 7579c40124c9b287bb67e974bda46e879e1a1ab1 (patch) | |
tree | bffcc91dca7c8f65ea744c06cc27b20403a30fed | |
parent | qt: Add support for new context flag "proc-all-sigs" (diff) | |
download | gpgme-7579c40124c9b287bb67e974bda46e879e1a1ab1.tar.gz gpgme-7579c40124c9b287bb67e974bda46e879e1a1ab1.zip |
cpp: Go with default answer on unknown question by key edit interface
* lang/cpp/src/editinteractor.cpp (edit_interactor_callback_impl):
Send empty string to edit interface if General Error occurred.
--
A General Error is usually returned by the nextState function of the
concrete EditInteractor subclasses if gpg asks an unexpected question
which isn't handled by the edit interactor's state machine. In this
case, it's usually safe to go with the default answer. This makes the
edit interactors much more robust.
GnuPG-bug-id: 7274
-rw-r--r-- | lang/cpp/src/editinteractor.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/lang/cpp/src/editinteractor.cpp b/lang/cpp/src/editinteractor.cpp index 84ddf398..5f9236cb 100644 --- a/lang/cpp/src/editinteractor.cpp +++ b/lang/cpp/src/editinteractor.cpp @@ -167,6 +167,20 @@ public: } error: + if (err.code() == GPG_ERR_GENERAL) { + // gpg may have asked an unknown question; try to use the default answer + if (ei->debug) { + std::fprintf(ei->debug, "EditInteractor: action result \"%s\" (go with the default answer)\n", ""); + } + if (writeAll(fd, "\n", 1) != 1) { + err = Error::fromSystemError(); + if (ei->debug) { + std::fprintf(ei->debug, "EditInteractor: Could not write to fd %d (%s)\n", fd, err.asStdString().c_str()); + } + } else { + err = Error(); + } + } if (err || err.isCanceled()) { ei->error = err; ei->state = EditInteractor::ErrorState; |