From 8f27511862cabac8fa1dd8f883cb78faebc05ef6 Mon Sep 17 00:00:00 2001 From: Andre Heinecke Date: Mon, 29 Oct 2018 16:11:22 +0100 Subject: [PATCH] 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. --- src/engine-gpgsm.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/engine-gpgsm.c b/src/engine-gpgsm.c index 3266e360..6e6df469 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