Possible bug in GPGME Python

meep meep at meeps.dev
Sat May 4 15:55:40 CEST 2024


Good day.

I would like to report what I believe to be an oversight in the Python
wrapper of GPGME.

I am reporting it here as it is a minor thing, and account creation is
disabled on the bug tracker at dev.gnupg.org. I would also prefer not
to make an account if possible.

In the interact(...) function of the Context class on line 1089 in
core.py it is checked whether a key is actually passed in to the
function:

if key is None:
    raise ValueError("First argument cannot be None")

Which is fine when editing a key, but when interacting with a smart
card (setting the flag INTERACT_CARD) - for example to generate a key
on it - there is not necessarily a key to be edited.

In interact_start(...) on line 131 of edit.c the presence of the key is
only checked if card_edit isn't set:

if ((card_edit == 0 && !key) || !fnc || !out)
  return gpg_error (GPG_ERR_INV_VALUE);

This functions is called by gpgme_op_interact(...) in the same file
which is called from Python in the aforementioned interact(...)
function.

Thus I believe that the intended behavior in Python would be to mirror
the C code and only check whether the key is None if INTERACT_CARD is
not set.

Please correct me if I am wrong and point me in the right direction.

Thanks in advance
- meep
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 854 bytes
Desc: This is a digitally signed message part
URL: <https://lists.gnupg.org/pipermail/gnupg-devel/attachments/20240504/8f391b92/attachment.sig>


More information about the Gnupg-devel mailing list