From ad9f6ae4b5e5a78d21d129fd249808842f49a226 Mon Sep 17 00:00:00 2001 From: David Shaw Date: Mon, 26 May 2003 13:21:12 +0000 Subject: [PATCH] * getkey.c (premerge_public_with_secret): Made "no secret subkey for" warning a verbose item and translatable. (From wk on stable branch) * sig-check.c (check_key_signature2): Made "no subkey for subkey binding packet" a verbose item instead of a !quiet one. There are too many garbled keys out in the wild. (From wk on stable branch) * filter.h: Remove const from WHAT. (From wk on stable branch) * progress.c (handle_progress): Store a copy of NAME. (progress_filter): Release WHAT, make sure not to print a NULL WHAT. (From wk on stable branch) * openfile.c (open_sigfile): Adjust free for new progress semantics. (From wk on stable branch) * plaintext.c (ask_for_detached_datafile): Don't dealloc pfx->WHAT. (From wk on stable branch) * seckey-cert.c (do_check): Issue the RSA_OR_IDEA status when the cipher algo is IDEA to make it easier to track down the problem. (From twoaday on stable branch) --- g10/ChangeLog | 26 ++++++++++++++++++++++++++ g10/filter.h | 2 +- g10/getkey.c | 5 +++-- g10/openfile.c | 3 +-- g10/plaintext.c | 6 ------ g10/progress.c | 18 +++++++++++++++--- g10/seckey-cert.c | 7 +++++-- g10/sig-check.c | 6 +++--- 8 files changed, 54 insertions(+), 19 deletions(-) diff --git a/g10/ChangeLog b/g10/ChangeLog index 77f09b6b1..7f0ec9503 100644 --- a/g10/ChangeLog +++ b/g10/ChangeLog @@ -1,3 +1,29 @@ +2003-05-26 David Shaw + + * getkey.c (premerge_public_with_secret): Made "no secret subkey + for" warning a verbose item and translatable. (From wk on stable + branch) + + * sig-check.c (check_key_signature2): Made "no subkey for subkey + binding packet" a verbose item instead of a !quiet one. There are + too many garbled keys out in the wild. (From wk on stable branch) + + * filter.h: Remove const from WHAT. (From wk on stable branch) + + * progress.c (handle_progress): Store a copy of + NAME. (progress_filter): Release WHAT, make sure not to print a + NULL WHAT. (From wk on stable branch) + + * openfile.c (open_sigfile): Adjust free for new progress + semantics. (From wk on stable branch) + + * plaintext.c (ask_for_detached_datafile): Don't dealloc + pfx->WHAT. (From wk on stable branch) + + * seckey-cert.c (do_check): Issue the RSA_OR_IDEA status when the + cipher algo is IDEA to make it easier to track down the + problem. (From twoaday on stable branch) + 2003-05-24 David Shaw * armor.c, g10.c, kbnode.c, misc.c, pkclist.c, sign.c, diff --git a/g10/filter.h b/g10/filter.h index d420d7c62..9f235fd6b 100644 --- a/g10/filter.h +++ b/g10/filter.h @@ -110,7 +110,7 @@ typedef struct { typedef struct { - const char *what; /* description */ + char *what; /* description */ u32 last_time; /* last time reported */ unsigned long last; /* last amount reported */ unsigned long offset; /* current amount */ diff --git a/g10/getkey.c b/g10/getkey.c index 789e2982f..122d17f26 100644 --- a/g10/getkey.c +++ b/g10/getkey.c @@ -2068,8 +2068,9 @@ premerge_public_with_secret ( KBNODE pubblock, KBNODE secblock ) if ( !sec ) { KBNODE next, ll; - log_info ( "no secret subkey " - "for public subkey %08lX - ignoring\n", + if (opt.verbose) + log_info ( _("no secret subkey " + "for public subkey %08lX - ignoring\n"), (ulong)keyid_from_pk (pk,NULL) ); /* we have to remove the subkey in this case */ assert ( last ); diff --git a/g10/openfile.c b/g10/openfile.c index 854589641..6f4541e80 100644 --- a/g10/openfile.c +++ b/g10/openfile.c @@ -282,8 +282,7 @@ open_sigfile( const char *iname, progress_filter_context_t *pfx ) log_info(_("assuming signed data in `%s'\n"), buf ); if (a && pfx) handle_progress (pfx, a, buf); - else - m_free(buf); + m_free(buf); } } return a; diff --git a/g10/plaintext.c b/g10/plaintext.c index 3183785b4..89043026c 100644 --- a/g10/plaintext.c +++ b/g10/plaintext.c @@ -358,14 +358,11 @@ ask_for_detached_datafile( MD_HANDLE md, MD_HANDLE md2, const char *inname, int textmode ) { progress_filter_context_t pfx; - int dealloc_pfx_name = 1; char *answer = NULL; IOBUF fp; int rc = 0; fp = open_sigfile( inname, &pfx ); /* open default file */ - if (!fp) - dealloc_pfx_name = 0; if( !fp && !opt.batch ) { int any=0; @@ -400,8 +397,6 @@ ask_for_detached_datafile( MD_HANDLE md, MD_HANDLE md2, } do_hash( md, md2, fp, textmode ); iobuf_close(fp); - if (dealloc_pfx_name) - m_free ((void *)pfx.what); leave: m_free(answer); @@ -428,7 +423,6 @@ hash_datafiles( MD_HANDLE md, MD_HANDLE md2, STRLIST files, if( fp ) { do_hash( md, md2, fp, textmode ); iobuf_close(fp); - m_free ((void *)pfx.what); return 0; } log_error (_("no signed data\n")); diff --git a/g10/progress.c b/g10/progress.c index 36b293ab5..bb414faae 100644 --- a/g10/progress.c +++ b/g10/progress.c @@ -45,7 +45,9 @@ progress_filter (void *opaque, int control, pfx->offset = 0; pfx->last_time = make_timestamp (); - sprintf (buffer, "%.20s ? %lu %lu", pfx->what, pfx->offset, + sprintf (buffer, "%.20s ? %lu %lu", + pfx->what? pfx->what : "?", + pfx->offset, pfx->total); write_status_text (STATUS_PROGRESS, buffer); } @@ -69,7 +71,9 @@ progress_filter (void *opaque, int control, { char buffer[50]; - sprintf (buffer, "%.20s ? %lu %lu", pfx->what, pfx->offset, + sprintf (buffer, "%.20s ? %lu %lu", + pfx->what? pfx->what : "?", + pfx->offset, pfx->total); write_status_text (STATUS_PROGRESS, buffer); @@ -77,6 +81,14 @@ progress_filter (void *opaque, int control, pfx->last_time = timestamp; } } + else if (control == IOBUFCTRL_FREE) + { + /* Note, that we must always dealloc resources of a filter + within the filter handler and not anywhere else. (We set it + to NULL and check all uses just in case.) */ + m_free (pfx->what); + pfx->what = NULL; + } else if (control == IOBUFCTRL_DESC) *(char**)buf = "progress_filter"; return rc; @@ -99,7 +111,7 @@ handle_progress (progress_filter_context_t *pfx, IOBUF inp, const char *name) filesize = opt.set_filesize; /* register the progress filter */ - pfx->what = name ? name : "stdin"; + pfx->what = m_strdup (name ? name : "stdin"); pfx->total = filesize; iobuf_push_filter (inp, progress_filter, pfx); } diff --git a/g10/seckey-cert.c b/g10/seckey-cert.c index 32c54498d..76f0ee28d 100644 --- a/g10/seckey-cert.c +++ b/g10/seckey-cert.c @@ -59,8 +59,11 @@ do_check( PKT_secret_key *sk, const char *tryagain_text, int mode, if( check_cipher_algo( sk->protect.algo ) ) { log_info(_("protection algorithm %d%s is not supported\n"), sk->protect.algo,sk->protect.algo==1?" (IDEA)":"" ); - if(sk->protect.algo==CIPHER_ALGO_IDEA) - idea_cipher_warn(0); + if (sk->protect.algo==CIPHER_ALGO_IDEA) + { + write_status (STATUS_RSA_OR_IDEA); + idea_cipher_warn (0); + } return G10ERR_CIPHER_ALGO; } keyid_from_sk( sk, keyid ); diff --git a/g10/sig-check.c b/g10/sig-check.c index 47ee6a293..107cac5bb 100644 --- a/g10/sig-check.c +++ b/g10/sig-check.c @@ -574,9 +574,9 @@ check_key_signature2( KBNODE root, KBNODE node, PKT_public_key *check_pk, md_close(md); } else { - if (!opt.quiet) - log_info ("key %08lX: no subkey for subkey " - "binding signature\n",(ulong)keyid_from_pk(pk,NULL)); + if (opt.verbose) + log_info ("key %08lX: no subkey for subkey binding packet\n", + (ulong)keyid_from_pk (pk, NULL)); rc = G10ERR_SIG_CLASS; } }