[git] GPGME - branch, master, updated. gpgme-1.12.0-26-g8f27511
by Andre Heinecke
cvs at cvs.gnupg.org
Mon Oct 29 16:15:41 CET 2018
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GnuPG Made Easy".
The branch, master has been updated
via 8f27511862cabac8fa1dd8f883cb78faebc05ef6 (commit)
via 62c736ba76a19d3b41af69e1f340a53b80f13fe0 (commit)
from 05a0e97f5c12c06082fbeab0fba6f86ddbfbe6b2 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 8f27511862cabac8fa1dd8f883cb78faebc05ef6
Author: Andre Heinecke <aheinecke at intevation.de>
Date: Mon Oct 29 16:11:22 2018 +0100
core: Do not crash if CMS plaintext is ignored
* src/engine-gpgsm.c (gpgsm_verify): Fix handling both
plaintext and signed_text as NULL.
--
Previously if plaintext was NULL and signed_text was NULL
it would set MESSAGE_FD to NULL which resulted in a
crash.
Ignoring the plaintext of an opaque signature might
make sense in some cases and engine-gpg handles it.
diff --git a/src/engine-gpgsm.c b/src/engine-gpgsm.c
index 3266e36..6e6df46 100644
--- a/src/engine-gpgsm.c
+++ b/src/engine-gpgsm.c
@@ -2030,11 +2030,19 @@ gpgsm_verify (void *engine, gpgme_data_t sig, gpgme_data_t signed_text,
err = gpgsm_set_fd (gpgsm, INPUT_FD, map_data_enc (gpgsm->input_cb.data));
if (err)
return err;
- if (plaintext)
+ if (!signed_text)
{
/* Normal or cleartext signature. */
- gpgsm->output_cb.data = plaintext;
- err = gpgsm_set_fd (gpgsm, OUTPUT_FD, 0);
+ if (plaintext)
+ {
+ gpgsm->output_cb.data = plaintext;
+ err = gpgsm_set_fd (gpgsm, OUTPUT_FD, 0);
+ }
+ else
+ {
+ /* No output requested. */
+ gpgsm_clear_fd (gpgsm, OUTPUT_FD);
+ }
gpgsm_clear_fd (gpgsm, MESSAGE_FD);
}
else
commit 62c736ba76a19d3b41af69e1f340a53b80f13fe0
Author: Andre Heinecke <aheinecke at intevation.de>
Date: Mon Oct 29 15:36:45 2018 +0100
cpp,tests: Add another test runner
* lang/cpp/tests/run-verify.cpp: New.
* lang/cpp/tests/Makefile.am: Update accordingly.
--
Add another test runner which helps to find problems on windows.
diff --git a/lang/cpp/tests/Makefile.am b/lang/cpp/tests/Makefile.am
index e9d9a57..67dd3d3 100644
--- a/lang/cpp/tests/Makefile.am
+++ b/lang/cpp/tests/Makefile.am
@@ -31,5 +31,6 @@ AM_CPPFLAGS = -I$(top_srcdir)/lang/cpp/src -I$(top_builddir)/src \
run_getkey_SOURCES = run-getkey.cpp
run_keylist_SOURCES = run-keylist.cpp
+run_verify_SOURCES = run-verify.cpp
-noinst_PROGRAMS = run-getkey run-keylist
+noinst_PROGRAMS = run-getkey run-keylist run-verify
diff --git a/lang/cpp/tests/run-verify.cpp b/lang/cpp/tests/run-verify.cpp
new file mode 100644
index 0000000..ec431e5
--- /dev/null
+++ b/lang/cpp/tests/run-verify.cpp
@@ -0,0 +1,186 @@
+/*
+ run-keylist.cpp
+
+ This file is part of GpgMEpp's test suite.
+ Copyright (c) 2018 Intevation GmbH
+
+ QGpgME is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License,
+ version 2, as published by the Free Software Foundation.
+
+ QGpgME is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+ In addition, as a special exception, the copyright holders give
+ permission to link the code of this program with any edition of
+ the Qt library by Trolltech AS, Norway (or with modified versions
+ of Qt that use the same license as Qt), and distribute linked
+ combinations including the two. You must obey the GNU General
+ Public License in all respects for all of the code used other than
+ Qt. If you modify this file, you may extend this exception to
+ your version of the file, but you are not obligated to do so. If
+ you do not wish to do so, delete this exception statement from
+ your version.
+*/
+#ifdef HAVE_CONFIG_H
+ #include "config.h"
+#endif
+
+#include "context.h"
+#include "key.h"
+#include "data.h"
+#include "verificationresult.h"
+
+#include <memory>
+#include <sstream>
+#include <iostream>
+
+using namespace GpgME;
+static int
+show_usage (int ex)
+{
+ fputs ("usage: run-verify [options] [DETACHEDSIGFILE] FILE\n\n"
+ "Options:\n"
+ " --verbose run in verbose mode\n"
+ " --openpgp use the OpenPGP protocol (default)\n"
+ " --cms use the CMS protocol\n"
+ " --sender MBOX use MBOX as sender address\n"
+ " --repeat N repeat it N times\n"
+ " --list-key list the signing key afterwards\n"
+ , stderr);
+ exit (ex);
+}
+
+int
+main (int argc, char **argv)
+{
+ int last_argc = -1;
+ Protocol protocol = OpenPGP;
+ std::string sender;
+ int repeats = 1;
+ bool verbose = false;
+ bool list_key = false;
+
+ if (argc)
+ { argc--; argv++; }
+
+ while (argc && last_argc != argc )
+ {
+ last_argc = argc;
+ if (!strcmp (*argv, "--"))
+ {
+ argc--; argv++;
+ break;
+ }
+ else if (!strcmp (*argv, "--help"))
+ show_usage (0);
+ else if (!strcmp (*argv, "--verbose"))
+ {
+ verbose = true;
+ argc--; argv++;
+ }
+ else if (!strcmp (*argv, "--list-key"))
+ {
+ list_key = true;
+ argc--; argv++;
+ }
+ else if (!strcmp (*argv, "--openpgp"))
+ {
+ protocol = OpenPGP;
+ argc--; argv++;
+ }
+ else if (!strcmp (*argv, "--cms"))
+ {
+ protocol = CMS;
+ argc--; argv++;
+ }
+ else if (!strcmp (*argv, "--sender"))
+ {
+ argc--; argv++;
+ if (!argc)
+ show_usage (1);
+ sender = *argv;
+ argc--; argv++;
+ }
+ else if (!strcmp (*argv, "--repeat"))
+ {
+ argc--; argv++;
+ if (!argc)
+ show_usage (1);
+ repeats = atoi (*argv);
+ argc--; argv++;
+ }
+ else if (!strncmp (*argv, "--", 2))
+ show_usage (1);
+ }
+
+ if (argc < 1 || argc > 2)
+ show_usage (1);
+
+ GpgME::initializeLibrary();
+
+ for (int i = 0; i < repeats; i++) {
+ std::cout << "Starting run: " << i << std::endl;
+ auto ctx = std::unique_ptr<Context> (Context::createForProtocol(protocol));
+ if (!ctx) {
+ std::cerr << "Failed to get Context";
+ return -1;
+ }
+
+ std::FILE *fp_sig = fopen (argv[0], "rb");
+ if (!fp_sig) {
+ std::cerr << "Failed to open sig file";
+ exit (1);
+ }
+
+ std::FILE *fp_msg = nullptr;
+ if (argc > 1)
+ {
+ fp_msg = fopen (argv[1], "rb");
+ if (!fp_msg) {
+ std::cerr << "Failed to open msg file";
+ exit (1);
+ }
+ }
+ Data dSig(fp_sig);
+ Data dMsg;
+ bool is_opaque = true;
+ if (fp_msg) {
+ dMsg = Data(fp_msg);
+ is_opaque = false;
+ }
+
+ if (!sender.empty()) {
+ ctx->setSender(sender.c_str());
+ }
+
+ Data output;
+ VerificationResult result;
+ if (is_opaque) {
+ result = ctx->verifyOpaqueSignature(dSig, output);
+ } else {
+ result = ctx->verifyDetachedSignature(dSig, dMsg);
+ }
+
+ Signature sig;
+ if (result.numSignatures()) {
+ sig = result.signature(0);
+ }
+
+ if (list_key && !sig.isNull()) {
+ sig.key(true, false);
+ }
+
+ if (verbose) {
+ std::cout << "Result: " << result << std::endl;
+ } else {
+ std::cout << "Err:" << result.error() << std::endl;
+ }
+ }
+}
-----------------------------------------------------------------------
Summary of changes:
lang/cpp/tests/Makefile.am | 3 +-
lang/cpp/tests/run-verify.cpp | 186 ++++++++++++++++++++++++++++++++++++++++++
src/engine-gpgsm.c | 14 +++-
3 files changed, 199 insertions(+), 4 deletions(-)
create mode 100644 lang/cpp/tests/run-verify.cpp
hooks/post-receive
--
GnuPG Made Easy
http://git.gnupg.org
More information about the Gnupg-commits
mailing list