aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--g10/ChangeLog8
-rw-r--r--g10/keygen.c60
-rw-r--r--g10/misc.c2
3 files changed, 40 insertions, 30 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 <[email protected]>
+
+ * 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 <[email protected]>
* 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
+ char *tok,*prefstring;
+
+ prefstring=m_strdup(string); /* need a writable string! */
+
+ while((tok=strsep(&prefstring," ,")))
{
- log_info (_("invalid item `%s' in preference string\n"),tok);
- rc=-1;
+ 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);
+ 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)