core: Check for unsupported export mode flags

src/engine-gpgsm.c (gpgsm_export, gpgsm_export_ext): Return error if an
unsupported mode flag is set.
--

The minimal mode flag has no effect for X.509 certificates, but we still
treat it as supported (as documented in the API documentation).

GnuPG-bug-id: 5757
This commit is contained in:
Ingo Klöcker 2022-01-03 14:55:49 +01:00
parent c0581adabe
commit c710af223c

View File

@ -1512,6 +1512,12 @@ gpgsm_export (void *engine, const char *pattern, gpgme_export_mode_t mode,
if (!gpgsm)
return gpg_error (GPG_ERR_INV_VALUE);
if ((mode & ~(GPGME_EXPORT_MODE_SECRET
|GPGME_EXPORT_MODE_MINIMAL
|GPGME_EXPORT_MODE_RAW
|GPGME_EXPORT_MODE_PKCS12)))
return gpg_error (GPG_ERR_NOT_SUPPORTED);
if (!pattern)
pattern = "";
@ -1559,6 +1565,12 @@ gpgsm_export_ext (void *engine, const char *pattern[], gpgme_export_mode_t mode,
if (!gpgsm)
return gpg_error (GPG_ERR_INV_VALUE);
if ((mode & ~(GPGME_EXPORT_MODE_SECRET
|GPGME_EXPORT_MODE_MINIMAL
|GPGME_EXPORT_MODE_RAW
|GPGME_EXPORT_MODE_PKCS12)))
return gpg_error (GPG_ERR_NOT_SUPPORTED);
if (pattern && *pattern)
{
const char **pat = pattern;