gpgme crasher on key enumeration

Stéphane Corthésy stephane at sente.ch
Mon Sep 17 12:04:02 CEST 2001


Hi,

I guess I discovered a bug in gpgme 0.2.2, when enumerating keys. 
Compile the following code (cc file.c -lgpgme), and execute it. Program 
will quit with the following message, when calling 
gpgme_op_keylist_next() after having obtained the last key from the 
second enumeration (normally function should return GPGME_EOF):

keylist.c:465: failed assertion `c->key_queue'

Note that if we don't start the first enumeration (with ctx2), 
everything works well (I know that this code does nothing, it's just 
here to show you the bug).


Stéphane


#include <gpgme.h>

int main(int argc, char *argv[])
{
	GpgmeCtx	ctx1, ctx2;
	GpgmeKey	key;
	int			i = 1;
	
	gpgme_check_engine();
	gpgme_new(&ctx1);
	gpgme_op_keylist_start(ctx1, "", 1);
	gpgme_new(&ctx2);
	gpgme_op_keylist_start(ctx2, "", 1);
	while(gpgme_op_keylist_next(ctx2, &key) != GPGME_EOF)
		/* If we don't enumerate, everything goes well... */;
	while(gpgme_op_keylist_next(ctx1, &key) != GPGME_EOF){
		const char	*str = gpgme_key_get_string_attr(key, 
GPGME_ATTR_KEYID, NULL, 0);
		
		printf("Key #%d: %s", i++, str);
	}
	
	return 0;
}




More information about the Gnupg-devel mailing list