* 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.
This commit is contained in:
David Shaw 2002-11-21 16:25:05 +00:00
parent 2e4e257f42
commit 1c6bcef3ce
3 changed files with 42 additions and 32 deletions

View 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

View 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
{
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)
{

View 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)