From c0581adabe7f5f63c0b96dac449790aa6ac4c291 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ingo=20Kl=C3=B6cker?= Date: Mon, 3 Jan 2022 14:49:40 +0100 Subject: [PATCH] core: Check for combination of ssh mode with other mode flags * src/export.c (check_mode): Return error if ssh mode is combined with another mode flag. -- The SSH mode flag cannot be used in combination with other flags. GnuPG-bug-id: 5757 --- src/export.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/export.c b/src/export.c index c07433b0..637badf9 100644 --- a/src/export.c +++ b/src/export.c @@ -128,6 +128,16 @@ check_mode (gpgme_export_mode_t mode, gpgme_protocol_t protocol, |GPGME_EXPORT_MODE_PKCS12))) return gpg_error (GPG_ERR_INV_VALUE); /* Invalid flags in MODE. */ + if ((mode & GPGME_EXPORT_MODE_SSH)) + { + if ((mode & (GPGME_EXPORT_MODE_EXTERN + |GPGME_EXPORT_MODE_MINIMAL + |GPGME_EXPORT_MODE_SECRET + |GPGME_EXPORT_MODE_RAW + |GPGME_EXPORT_MODE_PKCS12))) + return gpg_error (GPG_ERR_INV_FLAG); /* Combination not allowed. */ + } + if ((mode & GPGME_EXPORT_MODE_SECRET)) { if ((mode & GPGME_EXPORT_MODE_EXTERN))