Page MenuHome GnuPG

segv in gpgme when mixing keylist and delete
Closed, ResolvedPublic

Description

Reported by Daiki Ueno on gnupg-devel:

As gpgme_op_keylist_* are expected to be called in certain order, and
gpgme_op_delete resets the opdata, the following code dumps core on 1.

gpgme_new (&ctx);
gpgme_op_keylist_start (ctx, NULL, 0);
gpgme_op_keylist_next (ctx, &key);
gpgme_op_delete (ctx, key);
gpgme_op_keylist_next (ctx, &key); /* 1 */

Program terminated with signal 11, Segmentation fault.
#0 gpgme_op_keylist_next (ctx=0x804a030, r_key=0xbf867974) at keylist.c:887
887 if (!opd->key_queue)
(gdb) where
#0 gpgme_op_keylist_next (ctx=0x804a030, r_key=0xbf867974) at keylist.c:887
#1 0x0804866e in main () at test-keylist-next.c:28

Though this behavior might be intentional, may I request to change it to
return an error (possibly GPG_ERR_INV_STATE?) on 1 rather than SEGV?

Event Timeline

Hi,

I think that is fixed in revision 1183 with this change:

2006-10-23 Marcus Brinkmann <marcus@g10code.de>

  • keylist.c (gpgme_op_keylist_next): Return error if OPD is NULL.
marcus added a project: Restricted Project.Oct 23 2006, 6:58 PM
marcus removed subscribers: marcus, lmamane.

Daiki Ueno confirms this fix but asks whether this is also needed for
trustlist_next.

Fixed for trustlist_next as well.

2006-10-24 Marcus Brinkmann <marcus@g10code.de>

  • trustlist.c (gpgme_op_trustlist_next): Return error if OPD is NULL.
werner removed a project: Restricted Project.