From fa5982c96a3d17d6c61027e2ab4e7456d11348ef Mon Sep 17 00:00:00 2001 From: JP Rosevear Date: Mon, 22 Jan 2001 23:10:22 +0000 Subject: New function, can't use strlen on the md5 hash because it might have null 2001-01-22 JP Rosevear * e-dbhash.c (md5_to_dbt): New function, can't use strlen on the md5 hash because it might have null chars in it. (e_dbhash_add): use md5_to_dbt svn path=/trunk/; revision=7726 --- e-util/e-dbhash.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'e-util/e-dbhash.c') diff --git a/e-util/e-dbhash.c b/e-util/e-dbhash.c index 2bcedb8676..e286500066 100644 --- a/e-util/e-dbhash.c +++ b/e-util/e-dbhash.c @@ -55,6 +55,13 @@ string_to_dbt(const char *str, DBT *dbt) dbt->size = strlen (str) + 1; } +static void +md5_to_dbt(const char str[16], DBT *dbt) +{ + dbt->data = (void*)str; + dbt->size = 16; +} + void e_dbhash_add (EDbHash *edbh, const gchar *key, const gchar *data) { @@ -76,7 +83,7 @@ e_dbhash_add (EDbHash *edbh, const gchar *key, const gchar *data) /* Data dbt */ md5_get_digest (data, strlen (data), local_hash); - string_to_dbt (local_hash, &ddata); + md5_to_dbt (local_hash, &ddata); /* Add to database */ db->put (db, &dkey, &ddata, 0); -- cgit