* keygen.c (keygen_set_std_prefs): Properly handle an empty preference
authorDavid Shaw <dshaw@jabberwocky.com>
Thu, 21 Nov 2002 16:25:05 +0000 (16:25 +0000)
committerDavid Shaw <dshaw@jabberwocky.com>
Thu, 21 Nov 2002 16:25:05 +0000 (16:25 +0000)
string.

* misc.c (string_to_compress_algo): "none" is a bad choice since it
conflicts with the "none" in setpref.

g10/ChangeLog
g10/keygen.c
g10/misc.c

index 97b7af9..ad2e66e 100644 (file)
@@ -1,3 +1,11 @@
+2002-11-21  David Shaw  <dshaw@jabberwocky.com>
+
+       * 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  <dshaw@jabberwocky.com>
 
        * g10.c (main): Allow compression algorithm names as the argument
index 0a773ea..e2eb91b 100644 (file)
@@ -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)
       {
index 6781f77..fee040f 100644 (file)
@@ -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)