summaryrefslogtreecommitdiff
path: root/libsecret/secret-value.c
diff options
context:
space:
mode:
authorClaudio Saavedra <csaavedra@igalia.com>2013-02-27 11:11:48 +0200
committerClaudio Saavedra <csaavedra@igalia.com>2013-03-04 09:33:26 +0200
commitab239c7f6b05dbe9b62afe77225be95eb41c2e5e (patch)
treebdc726cfb2df9c255aa98158de38293386271378 /libsecret/secret-value.c
parentb11a7a2f81ac63a04875fd38b161ea1b6fb3d174 (diff)
downloadlibsecret-ab239c7f6b05dbe9b62afe77225be95eb41c2e5e.tar.gz
secret-value: allow empty strings
Passwords and other secrets are allowed to be empty strings, therefore the check for length != 0 is wrong. Add tests for empty SecretValue contents. https://bugzilla.gnome.org/show_bug.cgi?id=694787
Diffstat (limited to 'libsecret/secret-value.c')
-rw-r--r--libsecret/secret-value.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/libsecret/secret-value.c b/libsecret/secret-value.c
index a6fc5b8..cbfdf6b 100644
--- a/libsecret/secret-value.c
+++ b/libsecret/secret-value.c
@@ -97,14 +97,15 @@ secret_value_new (const gchar *secret,
{
gchar *copy;
- g_return_val_if_fail (secret == NULL || length != 0, NULL);
+ g_return_val_if_fail (length == 0 || secret != NULL, NULL);
g_return_val_if_fail (content_type, NULL);
if (length < 0)
length = strlen (secret);
copy = egg_secure_alloc (length + 1);
- memcpy (copy, secret, length);
+ if (secret)
+ memcpy (copy, secret, length);
copy[length] = 0;
return secret_value_new_full (copy, length, content_type, egg_secure_free);
}
@@ -132,7 +133,6 @@ secret_value_new_full (gchar *secret,
{
SecretValue *value;
- g_return_val_if_fail (secret == NULL || length != 0, NULL);
g_return_val_if_fail (content_type, NULL);
if (length < 0)