From 1c6bcef3ce677a4bda8d3586b85e12cbeda4c242 Mon Sep 17 00:00:00 2001 From: David Shaw Date: Thu, 21 Nov 2002 16:25:05 +0000 Subject: [PATCH] * keygen.c (keygen_set_std_prefs): Properly handle an empty preference string. * misc.c (string_to_compress_algo): "none" is a bad choice since it conflicts with the "none" in setpref. --- g10/ChangeLog | 8 +++++++ g10/keygen.c | 64 +++++++++++++++++++++++++++------------------------ g10/misc.c | 2 -- 3 files changed, 42 insertions(+), 32 deletions(-) diff --git a/g10/ChangeLog b/g10/ChangeLog index 97b7af9e8..ad2e66e7a 100644 --- a/g10/ChangeLog +++ b/g10/ChangeLog @@ -1,3 +1,11 @@ +2002-11-21 David Shaw + + * keygen.c (keygen_set_std_prefs): Properly handle an empty + preference string. + + * misc.c (string_to_compress_algo): "none" is a bad choice since + it conflicts with the "none" in setpref. + 2002-11-14 David Shaw * g10.c (main): Allow compression algorithm names as the argument diff --git a/g10/keygen.c b/g10/keygen.c index 0a773ea55..e2eb91bc5 100644 --- a/g10/keygen.c +++ b/g10/keygen.c @@ -215,7 +215,6 @@ keygen_set_std_prefs (const char *string,int personal) { byte sym[MAX_PREFS], hash[MAX_PREFS], zip[MAX_PREFS]; int nsym=0, nhash=0, nzip=0, mdc=1; /* mdc defaults on */ - char *tok,*prefstring; int val,rc = 0; if (!string || !ascii_strcasecmp (string, "default")) { @@ -237,37 +236,42 @@ keygen_set_std_prefs (const char *string,int personal) else if (!ascii_strcasecmp (string, "none")) string = ""; - prefstring=m_strdup(string); /* need a writable string! */ - - while((tok=strsep(&prefstring," ,"))) + if(strlen(string)) { - if((val=string_to_cipher_algo(tok))) - { - if(set_one_pref(val,1,tok,sym,&nsym)) - rc=-1; - } - else if((val=string_to_digest_algo(tok))) - { - if(set_one_pref(val,2,tok,hash,&nhash)) - rc=-1; - } - else if((val=string_to_compress_algo(tok))>-1) - { - if(set_one_pref(val,3,tok,zip,&nzip)) - rc=-1; - } - else if (ascii_strcasecmp(tok,"mdc")==0) - mdc=1; - else if (ascii_strcasecmp(tok,"no-mdc")==0) - mdc=0; - else - { - log_info (_("invalid item `%s' in preference string\n"),tok); - rc=-1; - } - } + char *tok,*prefstring; - m_free(prefstring); + prefstring=m_strdup(string); /* need a writable string! */ + + while((tok=strsep(&prefstring," ,"))) + { + if((val=string_to_cipher_algo(tok))) + { + if(set_one_pref(val,1,tok,sym,&nsym)) + rc=-1; + } + else if((val=string_to_digest_algo(tok))) + { + if(set_one_pref(val,2,tok,hash,&nhash)) + rc=-1; + } + else if((val=string_to_compress_algo(tok))>-1) + { + if(set_one_pref(val,3,tok,zip,&nzip)) + rc=-1; + } + else if (ascii_strcasecmp(tok,"mdc")==0) + mdc=1; + else if (ascii_strcasecmp(tok,"no-mdc")==0) + mdc=0; + else + { + log_info (_("invalid item `%s' in preference string\n"),tok); + rc=-1; + } + } + + m_free(prefstring); + } if(!rc) { diff --git a/g10/misc.c b/g10/misc.c index 6781f779c..fee040f86 100644 --- a/g10/misc.c +++ b/g10/misc.c @@ -543,8 +543,6 @@ string_to_compress_algo(const char *string) { if(ascii_strcasecmp(string,"uncompressed")==0) return 0; - else if(ascii_strcasecmp(string,"none")==0) - return 0; else if(ascii_strcasecmp(string,"zip")==0) return 1; else if(ascii_strcasecmp(string,"zlib")==0)