Fixed a keylisting bug
This commit is contained in:
parent
0bc8c1c7e1
commit
b4eddd3042
2
NEWS
2
NEWS
@ -10,7 +10,7 @@ Noteworthy changes in version 0.2.3 (2001-09-17)
|
||||
|
||||
* Added a simple encryption component for MS-Windows; however the
|
||||
build procedure might have some problems.
|
||||
o
|
||||
|
||||
Noteworthy changes in version 0.2.2 (2001-06-12)
|
||||
------------------------------------------------
|
||||
|
||||
|
@ -31,7 +31,7 @@ AM_MAINTAINER_MODE
|
||||
# AGE, set REVISION to 0.
|
||||
# 3. Interfaces removed (BAD, breaks upward compatibility): Increment
|
||||
# CURRENT, set AGE and REVISION to 0.
|
||||
AM_INIT_AUTOMAKE(gpgme,0.2.3)
|
||||
AM_INIT_AUTOMAKE(gpgme,0.2.3a)
|
||||
#
|
||||
LIBGPGME_LT_CURRENT=4
|
||||
LIBGPGME_LT_AGE=4
|
||||
|
@ -1,3 +1,11 @@
|
||||
2001-09-17 Werner Koch <wk@gnupg.org>
|
||||
|
||||
* keylist.c (finish_key): Shortcut for no tmp_key. Changed all
|
||||
callers to use this function without a check for tmp_key.
|
||||
|
||||
* keylist.c (gpgme_op_keylist_next): Reset the key_cond after
|
||||
emptying the queue. Bug reported by Rick van Rein.
|
||||
|
||||
2001-09-12 Werner Koch <wk@gnupg.org>
|
||||
|
||||
* data.c (gpgme_data_rewind): Allow rewind for callbacks.
|
||||
|
@ -88,7 +88,7 @@ typedef enum {
|
||||
GPGME_No_Passphrase = 19,
|
||||
GPGME_Canceled = 20,
|
||||
GPGME_Invalid_Key = 21,
|
||||
GPGME_Invalid_Engine = 22,
|
||||
GPGME_Invalid_Engine = 22
|
||||
} GpgmeError;
|
||||
|
||||
typedef enum {
|
||||
|
@ -44,8 +44,7 @@ keylist_status_handler ( GpgmeCtx ctx, GpgStatusCode code, char *args )
|
||||
|
||||
switch (code) {
|
||||
case STATUS_EOF:
|
||||
if (ctx->tmp_key)
|
||||
finish_key (ctx);
|
||||
finish_key (ctx);
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -157,8 +156,7 @@ keylist_colon_handler ( GpgmeCtx ctx, char *line )
|
||||
if ( ctx->out_of_core )
|
||||
return;
|
||||
if (!line) { /* EOF */
|
||||
if (ctx->tmp_key)
|
||||
finish_key (ctx);
|
||||
finish_key (ctx);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -198,8 +196,7 @@ keylist_colon_handler ( GpgmeCtx ctx, char *line )
|
||||
return;
|
||||
}
|
||||
rectype = RT_PUB;
|
||||
if ( ctx->tmp_key )
|
||||
finish_key ( ctx );
|
||||
finish_key ( ctx );
|
||||
assert ( !ctx->tmp_key );
|
||||
ctx->tmp_key = key;
|
||||
}
|
||||
@ -210,8 +207,7 @@ keylist_colon_handler ( GpgmeCtx ctx, char *line )
|
||||
return;
|
||||
}
|
||||
rectype = RT_SEC;
|
||||
if ( ctx->tmp_key )
|
||||
finish_key ( ctx );
|
||||
finish_key ( ctx );
|
||||
assert ( !ctx->tmp_key );
|
||||
ctx->tmp_key = key;
|
||||
}
|
||||
@ -345,29 +341,30 @@ finish_key ( GpgmeCtx ctx )
|
||||
GpgmeKey key = ctx->tmp_key;
|
||||
struct key_queue_item_s *q, *q2;
|
||||
|
||||
assert (key);
|
||||
ctx->tmp_key = NULL;
|
||||
|
||||
_gpgme_key_cache_add (key);
|
||||
|
||||
q = xtrymalloc ( sizeof *q );
|
||||
if ( !q ) {
|
||||
gpgme_key_release (key);
|
||||
ctx->out_of_core = 1;
|
||||
return;
|
||||
if (key) {
|
||||
ctx->tmp_key = NULL;
|
||||
|
||||
_gpgme_key_cache_add (key);
|
||||
|
||||
q = xtrymalloc ( sizeof *q );
|
||||
if ( !q ) {
|
||||
gpgme_key_release (key);
|
||||
ctx->out_of_core = 1;
|
||||
return;
|
||||
}
|
||||
q->key = key;
|
||||
q->next = NULL;
|
||||
/* fixme: lock queue. Use a tail pointer? */
|
||||
if ( !(q2 = ctx->key_queue) )
|
||||
ctx->key_queue = q;
|
||||
else {
|
||||
for ( ; q2->next; q2 = q2->next )
|
||||
;
|
||||
q2->next = q;
|
||||
}
|
||||
ctx->key_cond = 1;
|
||||
/* fixme: unlock queue */
|
||||
}
|
||||
q->key = key;
|
||||
q->next = NULL;
|
||||
/* fixme: lock queue. Use a tail pointer? */
|
||||
if ( !(q2 = ctx->key_queue) )
|
||||
ctx->key_queue = q;
|
||||
else {
|
||||
for ( ; q2->next; q2 = q2->next )
|
||||
;
|
||||
q2->next = q;
|
||||
}
|
||||
ctx->key_cond = 1;
|
||||
/* fixme: unlock queue */
|
||||
}
|
||||
|
||||
|
||||
@ -482,6 +479,8 @@ gpgme_op_keylist_next ( GpgmeCtx c, GpgmeKey *r_key )
|
||||
}
|
||||
q = c->key_queue;
|
||||
c->key_queue = q->next;
|
||||
if (!c->key_queue)
|
||||
c->key_cond = 0;
|
||||
|
||||
*r_key = q->key;
|
||||
xfree (q);
|
||||
|
@ -139,7 +139,7 @@ _gpgme_remove_proc_from_wait_queue ( int pid )
|
||||
* @hang:
|
||||
*
|
||||
* Wait for a finished request, if @c is given the function does only
|
||||
* wait on a finsihed request for that context, otherwise it will return
|
||||
* wait on a finished request for that context, otherwise it will return
|
||||
* on any request. When @hang is true the function will wait, otherwise
|
||||
* it will return immediately when there is no pending finished request.
|
||||
*
|
||||
|
@ -94,6 +94,34 @@ doit ( GpgmeCtx ctx, const char *pattern )
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Check that there are no problems when we are using two context for
|
||||
* listing keys.
|
||||
*/
|
||||
static void
|
||||
check_two_contexts (void)
|
||||
{
|
||||
GpgmeError err;
|
||||
GpgmeCtx ctx1, ctx2;
|
||||
GpgmeKey key;
|
||||
|
||||
err = gpgme_new(&ctx1); fail_if_err (err);
|
||||
err = gpgme_op_keylist_start(ctx1, "", 1); fail_if_err (err);
|
||||
err = gpgme_new(&ctx2); fail_if_err (err);
|
||||
err = gpgme_op_keylist_start(ctx2, "", 1); fail_if_err (err);
|
||||
|
||||
while ( (err=gpgme_op_keylist_next(ctx2, &key)) != GPGME_EOF) {
|
||||
gpgme_key_release (key);
|
||||
}
|
||||
if (err != GPGME_EOF)
|
||||
fail_if_err (err);
|
||||
while ( (err=gpgme_op_keylist_next(ctx1, &key)) != GPGME_EOF) {
|
||||
gpgme_key_release (key);
|
||||
}
|
||||
if (err != GPGME_EOF)
|
||||
fail_if_err (err);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char **argv )
|
||||
{
|
||||
@ -112,6 +140,9 @@ main (int argc, char **argv )
|
||||
}
|
||||
pattern = argc? *argv : NULL;
|
||||
|
||||
err = gpgme_check_engine();
|
||||
fail_if_err (err);
|
||||
|
||||
err = gpgme_new (&ctx);
|
||||
fail_if_err (err);
|
||||
gpgme_set_keylist_mode (ctx, 1); /* no validity calculation */
|
||||
@ -121,6 +152,8 @@ main (int argc, char **argv )
|
||||
} while ( loop );
|
||||
gpgme_release (ctx);
|
||||
|
||||
check_two_contexts ();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user