GPGME: gpgme_get_key bug
Giacomo Tesio <[email protected]> Sat, 8 Nov 2025 15:29:09 +0100
| Newsgroups | gmane.comp.encryption.gpg.devel |
|---|---|
| Message-ID | <[email protected]> |
Hi, while working on a patch for Claws-Mail, I realized that gpgme_get_key ignores context configuration set with either gpgme_set_ctx_flag or gpgme_set_offline. Looking at the source code in gpgme/src/keylist.c, I saw that a new listctx is created "to avoid the user's I/O callback handlers" and part of the calling ctx's configuration is copied there. However, imho, at least "auto-key-locate" ctx flag and offline mode should be copied too, to actually serve the caller's request, as they may impact the key retrieval. You can find a patch attached. Cheers, Giacomo PS: I tried to report this on bugzilla, but the registration page suggest to ask here for credentials. Feel free to use "giacomo" as handle, "Giacomo Tesio" as shown name, and this address as email. _______________________________________________ Gnupg-devel mailing list [email protected] https://lists.gnupg.org/mailman/listinfo/gnupg-devel
0001-gpgme_get_key-respect-caller-s-ctx-configuration.patch
(text/x-patch, 1.1 KB)
From 87e4ffeae92cfdd13161c65186d534989d5c9f91 Mon Sep 17 00:00:00 2001 From: Giacomo Tesio <[email protected]> Date: Sat, 8 Nov 2025 14:47:53 +0100 Subject: [PATCH] gpgme_get_key: respect caller's ctx configuration --- src/keylist.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/keylist.c b/src/keylist.c index 3246aaf0..67ac0fba 100644 --- a/src/keylist.c +++ b/src/keylist.c @@ -1534,13 +1534,18 @@ gpgme_get_key (gpgme_ctx_t ctx, const char *fpr, gpgme_key_t *r_key, if (err) return TRACE_ERR (err); { + const char *ctx_flag; gpgme_protocol_t proto; gpgme_engine_info_t info; /* Clone the relevant state. */ proto = gpgme_get_protocol (ctx); gpgme_set_protocol (listctx, proto); + gpgme_set_offline (listctx, gpgme_get_offline (ctx)); gpgme_set_keylist_mode (listctx, gpgme_get_keylist_mode (ctx)); + ctx_flag = gpgme_get_ctx_flag (ctx, "auto-key-locate"); + if (ctx_flag != NULL) + gpgme_set_ctx_flag (listctx, "auto-key-locate", ctx_flag); info = gpgme_ctx_get_engine_info (ctx); while (info && info->protocol != proto) info = info->next; -- 2.47.3
signature.asc
(application/pgp-signature, 833 B)
-----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEv6qRO0JUQmMDkeHjZivWmLlQnZEFAmkPU7UACgkQZivWmLlQ nZGuRA/+M3a8xonxhNcZ0KYblB9+wjaEul4Vnnu087c/FwRacaL8pu8bwrIJkJUw Y/miHUS3Sdbvw5nUbuw5eQV3w7koRY4/bdPkwCcS39UBcB8rDo06pAUhnXQ0FIjz 2hBR+XyawvG375qT8g5AjCG9xvly7rXwVzeazT5E70uOmiKWyiRhe0VZ+2v/HGjj TROlUGM29rdNVx+fSvJFaxtMUdMJkq360mnGTaYBCxB7HTHOEsqHn8BhrDVuDvWx p/plAzlOZNL8gqQjWhvI5gOgHXpKAGtNmGVzOd9OAiV1HrSfOuYa2vWI1WYb5uzN zPh2va/EIA+KUGB3PWucXNWXBcimmDCKApKKEO5bLDNovB9yxFlPFtN7cS8xBB+d /QZmgPA54/9hwLAh5mrgpoHKxvevsgvWTZlbbiulUPbuOppmmQLHqFS0po9SEGiv /nvrgf+oF9TfSdDjaeMgmCtXzLtOUyOyLDxpkc/WJSxNQe4QiqoU4YZNS9gedDBf B9/HRgR/gQ7TWPMzoTWRZucBwYvb2eCM45OgtEoihPkdmMxUMnfh2eJh8ZOcROjC mQf9+GkPaKp+LZVpFRU9ZTFDurfjaA5AEI4GNNw2sDNpIfpRvFn36AuQvvlSQT5m AdRz7/mtxSOrv4uQo1KFlORQyoZqjCS3/sJ4vmR6qMxV+QoGIQk= =1MKu -----END PGP SIGNATURE-----