summaryrefslogtreecommitdiff
path: root/src/peerstore/plugin_peerstore_flat.c
diff options
context:
space:
mode:
authorMartin Schanzenbach <mschanzenbach@posteo.de>2016-07-07 12:42:16 +0000
committerMartin Schanzenbach <mschanzenbach@posteo.de>2016-07-07 12:42:16 +0000
commit8586fb8f07b38537a4a13f84610636461a9d24eb (patch)
tree25a131fdcbf37f07cb850aef5062930eaad5b3f6 /src/peerstore/plugin_peerstore_flat.c
parentaf219c4cff61abd088f89c8a5029af1d449a78b6 (diff)
-coverity
Diffstat (limited to 'src/peerstore/plugin_peerstore_flat.c')
-rw-r--r--src/peerstore/plugin_peerstore_flat.c32
1 files changed, 25 insertions, 7 deletions
diff --git a/src/peerstore/plugin_peerstore_flat.c b/src/peerstore/plugin_peerstore_flat.c
index fd417be05..c95146de6 100644
--- a/src/peerstore/plugin_peerstore_flat.c
+++ b/src/peerstore/plugin_peerstore_flat.c
@@ -337,11 +337,13 @@ database_setup (struct Plugin *plugin)
char *afsdir;
char *key;
char *sub_system;
- char *peer_id;
+ const char *peer_id;
+ char *peer;
char *value;
char *expiry;
struct GNUNET_DISK_FileHandle *fh;
struct GNUNET_PEERSTORE_Record *entry;
+ struct GNUNET_HashCode hkey;
size_t size;
char *buffer;
char *line;
@@ -416,8 +418,8 @@ database_setup (struct Plugin *plugin)
sub_system = strtok (line, ",");
if (NULL == sub_system)
break;
- peer_id = strtok (NULL, ",");
- if (NULL == peer_id)
+ peer = strtok (NULL, ",");
+ if (NULL == peer)
break;
key = strtok (NULL, ",");
if (NULL == key)
@@ -431,14 +433,30 @@ database_setup (struct Plugin *plugin)
entry = GNUNET_new (struct GNUNET_PEERSTORE_Record);
entry->sub_system = GNUNET_strdup (sub_system);
entry->key = GNUNET_strdup (key);
- GNUNET_STRINGS_base64_decode (peer_id,
- strlen (peer_id),
+ GNUNET_STRINGS_base64_decode (peer,
+ strlen (peer),
(char**)&entry->peer);
entry->value_size = GNUNET_STRINGS_base64_decode (value,
strlen (value),
(char**)&entry->value);
- GNUNET_STRINGS_fancy_time_to_absolute (expiry,
- entry->expiry);
+ if (GNUNET_SYSERR == GNUNET_STRINGS_fancy_time_to_absolute (expiry,
+ entry->expiry))
+ {
+ GNUNET_free (entry->sub_system);
+ GNUNET_free (entry->key);
+ GNUNET_free (entry->peer);
+ GNUNET_free (entry);
+ break;
+ }
+ peer_id = GNUNET_i2s (entry->peer);
+ GNUNET_CRYPTO_hash (peer_id,
+ strlen (peer_id),
+ &hkey);
+
+ GNUNET_assert (GNUNET_OK == GNUNET_CONTAINER_multihashmap_put (plugin->hm,
+ &hkey,
+ entry,
+ GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE));
}
}