mirror of
git://git.gnupg.org/gnupg.git
synced 2024-12-22 10:19:57 +01:00
common: Check wether to set the modified flag in nve_set.
* common/name-value.c (nvc_set): Factor code out to ... (nve_set): here.
This commit is contained in:
parent
cf2d3f7ba0
commit
813bb65d95
@ -495,34 +495,13 @@ gpg_error_t
|
||||
nvc_set (nvc_t pk, const char *name, const char *value)
|
||||
{
|
||||
nve_t e;
|
||||
char *v;
|
||||
|
||||
if (! valid_name (name))
|
||||
return GPG_ERR_INV_NAME;
|
||||
|
||||
e = nvc_lookup (pk, name);
|
||||
if (e)
|
||||
{
|
||||
if (e->value && value && !strcmp (e->value, value))
|
||||
{
|
||||
/* Setting same value - ignore this call and don't set the
|
||||
* modified flag. */
|
||||
return 0;
|
||||
}
|
||||
|
||||
v = xtrystrdup (value);
|
||||
if (v == NULL)
|
||||
return my_error_from_syserror ();
|
||||
|
||||
free_strlist_wipe (e->raw_value);
|
||||
e->raw_value = NULL;
|
||||
if (e->value)
|
||||
wipememory (e->value, strlen (e->value));
|
||||
xfree (e->value);
|
||||
e->value = v;
|
||||
pk->modified = 1;
|
||||
return 0;
|
||||
}
|
||||
return nve_set (pk, e, value);
|
||||
else
|
||||
return nvc_add (pk, name, value);
|
||||
}
|
||||
@ -538,6 +517,13 @@ nve_set (nvc_t pk, nve_t e, const char *value)
|
||||
if (!e)
|
||||
return GPG_ERR_INV_ARG;
|
||||
|
||||
if (e->value && value && !strcmp (e->value, value))
|
||||
{
|
||||
/* Setting same value - ignore this call and don't set the
|
||||
* modified flag (if PK is given). */
|
||||
return 0;
|
||||
}
|
||||
|
||||
v = xtrystrdup (value? value:"");
|
||||
if (!v)
|
||||
return my_error_from_syserror ();
|
||||
|
Loading…
x
Reference in New Issue
Block a user