Make handling of new conf values more robust (bug#1413).
* src/engine-gpgconf.c (arg_to_data): Allow for NULL as value.string. -- I was not able to replicate the problem. However this patch makes the code more robust and tolerates errors by the user. IT should fix the problem at hand.
This commit is contained in:
parent
4751a0e1bc
commit
9f081da735
@ -754,36 +754,37 @@ arg_to_data (gpgme_data_t conf, gpgme_conf_opt_t option, gpgme_conf_arg_t arg)
|
||||
case GPGME_CONF_PUB_KEY:
|
||||
case GPGME_CONF_SEC_KEY:
|
||||
case GPGME_CONF_ALIAS_LIST:
|
||||
/* One quote character, and three times to allow
|
||||
for percent escaping. */
|
||||
{
|
||||
char *ptr = arg->value.string;
|
||||
amt = gpgme_data_write (conf, "\"", 1);
|
||||
if (amt < 0)
|
||||
break;
|
||||
if (arg->value.string)
|
||||
{
|
||||
/* One quote character, and three times to allow for
|
||||
percent escaping. */
|
||||
char *ptr = arg->value.string;
|
||||
amt = gpgme_data_write (conf, "\"", 1);
|
||||
if (amt < 0)
|
||||
break;
|
||||
|
||||
while (!err && *ptr)
|
||||
{
|
||||
switch (*ptr)
|
||||
{
|
||||
case '%':
|
||||
amt = gpgme_data_write (conf, "%25", 3);
|
||||
break;
|
||||
while (!err && *ptr)
|
||||
{
|
||||
switch (*ptr)
|
||||
{
|
||||
case '%':
|
||||
amt = gpgme_data_write (conf, "%25", 3);
|
||||
break;
|
||||
|
||||
case ':':
|
||||
amt = gpgme_data_write (conf, "%3a", 3);
|
||||
break;
|
||||
case ':':
|
||||
amt = gpgme_data_write (conf, "%3a", 3);
|
||||
break;
|
||||
|
||||
case ',':
|
||||
amt = gpgme_data_write (conf, "%2c", 3);
|
||||
break;
|
||||
case ',':
|
||||
amt = gpgme_data_write (conf, "%2c", 3);
|
||||
break;
|
||||
|
||||
default:
|
||||
amt = gpgme_data_write (conf, ptr, 1);
|
||||
}
|
||||
ptr++;
|
||||
}
|
||||
}
|
||||
default:
|
||||
amt = gpgme_data_write (conf, ptr, 1);
|
||||
}
|
||||
ptr++;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user