From ebd148e55343a4de846936124456bf2491484603 Mon Sep 17 00:00:00 2001 From: David Shaw Date: Fri, 7 Dec 2001 00:57:50 +0000 Subject: [PATCH] Bug fix in "showpref" Allow setting a no-compression preference --- g10/ChangeLog | 14 ++++++++++++++ g10/g10.c | 7 +++++-- g10/getkey.c | 2 +- g10/keyedit.c | 29 +++++++++++++++++++++++++++++ g10/keygen.c | 2 +- 5 files changed, 50 insertions(+), 4 deletions(-) diff --git a/g10/ChangeLog b/g10/ChangeLog index 4454f2238..0f4822f9a 100644 --- a/g10/ChangeLog +++ b/g10/ChangeLog @@ -1,3 +1,17 @@ +2001-11-16 David Shaw + + * Allow the user to select no compression via "--compress-algo 0" + on the command line. + + * keyedit.c (show_prefs): Show compression preferences in the + long-form "showpref" style. + + * keygen.c (set_one_pref): Permit setting a no-compression ("Z0") + preference. + + * getkey.c (fixup_uidnode): Fix compression preference corruption + bug. + 2001-12-02 David Shaw * g10.c: Add advisory --for-your-eyes-only option as per section diff --git a/g10/g10.c b/g10/g10.c index 212a44889..25a3d9fc4 100644 --- a/g10/g10.c +++ b/g10/g10.c @@ -1238,8 +1238,8 @@ main( int argc, char **argv ) if( check_policy_url( opt.set_policy_url ) ) log_error(_("the given policy URL is invalid\n")); } - if( opt.def_compress_algo < 1 || opt.def_compress_algo > 2 ) - log_error(_("compress algorithm must be in range %d..%d\n"), 1, 2); + if( opt.def_compress_algo < 0 || opt.def_compress_algo > 2 ) + log_error(_("compress algorithm must be in range %d..%d\n"), 0, 2); if( opt.completes_needed < 1 ) log_error(_("completes-needed must be greater than 0\n")); if( opt.marginals_needed < 2 ) @@ -1290,6 +1290,9 @@ main( int argc, char **argv ) g10_opt_verbose = opt.verbose; } + /* Compression algorithm 0 means no compression at all */ + if( opt.def_compress_algo == 0) + opt.compress = 0; /* kludge to let -sat generate a clear text signature */ if( opt.textmode == 2 && !detached_sig && opt.armor && cmd == aSign ) diff --git a/g10/getkey.c b/g10/getkey.c index 7236c4042..d8695ee78 100644 --- a/g10/getkey.c +++ b/g10/getkey.c @@ -1163,7 +1163,7 @@ fixup_uidnode ( KBNODE uidnode, KBNODE signode, u32 keycreated ) } for (; nzip; nzip--, n++) { uid->prefs[n].type = PREFTYPE_ZIP; - uid->prefs[n].value = *sym++; + uid->prefs[n].value = *zip++; } uid->prefs[n].type = PREFTYPE_NONE; /* end of list marker */ uid->prefs[n].value = 0; diff --git a/g10/keyedit.c b/g10/keyedit.c index 3bda19cf4..bc262ba7c 100644 --- a/g10/keyedit.c +++ b/g10/keyedit.c @@ -1175,6 +1175,35 @@ show_prefs (PKT_user_id *uid, int verbose) tty_printf ("[%d]", prefs[i].value); } } + tty_printf ("\n Compression: "); + for(i=any=0; prefs[i].type; i++ ) { + if( prefs[i].type == PREFTYPE_ZIP ) { + const char *s=NULL; + switch(prefs[i].value) + { + case 0: + s="Uncompressed"; + break; + + case 1: + s="ZIP"; + break; + + case 2: + s="ZLIB"; + break; + } + + if (any) + tty_printf (", "); + any = 1; + /* We don't want to display strings for experimental algos */ + if (s && prefs[i].value < 100 ) + tty_printf ("%s", s ); + else + tty_printf ("[%d]", prefs[i].value); + } + } tty_printf("\n"); } else { diff --git a/g10/keygen.c b/g10/keygen.c index f30e49891..b9e486886 100644 --- a/g10/keygen.c +++ b/g10/keygen.c @@ -175,7 +175,7 @@ set_one_pref (ulong val, int type, int (*cf)(int), byte *buf, int *nbuf) { int i; - if (!val || val > 127 || cf (val)) { + if (cf (val)) { log_info (_("preference %c%lu is not valid\n"), type, val); return -1; }