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.
This commit is contained in:
Andre Heinecke 2018-10-29 16:11:22 +01:00
parent 62c736ba76
commit 8f27511862
No known key found for this signature in database
GPG Key ID: 2978E9D40CBABA5C

View File

@ -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)); err = gpgsm_set_fd (gpgsm, INPUT_FD, map_data_enc (gpgsm->input_cb.data));
if (err) if (err)
return err; return err;
if (plaintext) if (!signed_text)
{ {
/* Normal or cleartext signature. */ /* Normal or cleartext signature. */
gpgsm->output_cb.data = plaintext; if (plaintext)
err = gpgsm_set_fd (gpgsm, OUTPUT_FD, 0); {
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); gpgsm_clear_fd (gpgsm, MESSAGE_FD);
} }
else else