Package: libgpgme11
Version: 1.0.2-1
Severity: important
Starting asynchronouse call and then canceling it with gpgme_cancel do cause
gpgme_wait() return Canceled error but leaves gpg process working and
finishing the call.
Attached is a slightly modified t-genkey test from the gpgme source showing
the problem.
Igor
-- System Information:
Debian Release: 3.1
APT prefers unstable
APT policy: (500, 'unstable')
Architecture: i386 (i686)
Kernel: Linux 2.6.11
Locale: LANG=C, LC_CTYPE=ru_RU.KOI8-R (charmap=KOI8-R)
Versions of packages libgpgme11 depends on:
ii gnupg 1.4.0-3 GNU privacy guard - a free PGP rep
ii libc6 2.3.2.ds1-20 GNU C Library: Shared libraries an
ii libgpg-error0 1.0-1 library for common error values an
-- no debconf information
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <gpgme.h>
#include "t-support.h"
/* True if progress function printed something on the screen. */
static int progress_called;
static void
progress (void *self, const char *what, int type, int current, int total)
{
printf ("%c", type);
fflush (stdout);
progress_called++;
}
int
main (int argc, char **argv)
{
gpgme_ctx_t ctx;
gpgme_error_t err;
const char *parms = "<GnupgKeyParms format=\"internal\">\n"
"Key-Type: DSA\n"
"Key-Length: 1024\n"
"Subkey-Type: ELG-E\n"
"Subkey-Length: 4096\n"
"Name-Real: Joe Tester\n"
"Name-Comment: (pp=abc)\n"
"Name-Email: [EMAIL PROTECTED]"
"Expire-Date: 0\n"
"Passphrase: abc\n"
"</GnupgKeyParms>\n";
gpgme_genkey_result_t result;
if (argc != 2) {
fprintf(stderr, "Usage: %s <sync|async>\n", argv[0]);
exit(1);
}
init_gpgme (GPGME_PROTOCOL_OpenPGP);
err = gpgme_new (&ctx);
fail_if_err (err);
gpgme_set_progress_cb (ctx, progress, NULL);
if (argv[1][0] == 'a' || argv[1][0] == '0') {
err = gpgme_op_genkey_start (ctx, parms, NULL, NULL);
fail_if_err (err);
err = 0xFFFF;
progress_called = 0;
do {
if (progress_called > 100) {
gpgme_cancel(ctx);
printf ("(Cancel is called)\n");
fflush(stdout);
}
gpgme_wait(ctx, &err, 0);
} while (err == 0xFFFF);
if (err != 0xFFFF)
fail_if_err (err);
} else {
err = gpgme_op_genkey (ctx, parms, NULL, NULL);
fail_if_err (err);
}
result = gpgme_op_genkey_result (ctx);
if (!result)
{
fprintf (stderr, "%s:%d: gpgme_op_genkey_result returns NULL\n",
__FILE__, __LINE__);
exit (1);
}
if (progress_called)
printf ("\n");
printf ("Generated key: %s (%s)\n", result->fpr ? result->fpr : "none",
result->primary ? (result->sub ? "primary, sub" : "primary")
: (result->sub ? "sub" : "none"));
gpgme_release (ctx);
return 0;
}