diff options
author | Martin Schanzenbach <mschanzenbach@posteo.de> | 2016-07-07 12:42:16 +0000 |
---|---|---|
committer | Martin Schanzenbach <mschanzenbach@posteo.de> | 2016-07-07 12:42:16 +0000 |
commit | 8586fb8f07b38537a4a13f84610636461a9d24eb (patch) | |
tree | 25a131fdcbf37f07cb850aef5062930eaad5b3f6 /src/peerstore/plugin_peerstore_flat.c | |
parent | af219c4cff61abd088f89c8a5029af1d449a78b6 (diff) | |
download | gnunet-8586fb8f07b38537a4a13f84610636461a9d24eb.tar.gz gnunet-8586fb8f07b38537a4a13f84610636461a9d24eb.zip |
-coverity
Diffstat (limited to 'src/peerstore/plugin_peerstore_flat.c')
-rw-r--r-- | src/peerstore/plugin_peerstore_flat.c | 32 |
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) | |||
337 | char *afsdir; | 337 | char *afsdir; |
338 | char *key; | 338 | char *key; |
339 | char *sub_system; | 339 | char *sub_system; |
340 | char *peer_id; | 340 | const char *peer_id; |
341 | char *peer; | ||
341 | char *value; | 342 | char *value; |
342 | char *expiry; | 343 | char *expiry; |
343 | struct GNUNET_DISK_FileHandle *fh; | 344 | struct GNUNET_DISK_FileHandle *fh; |
344 | struct GNUNET_PEERSTORE_Record *entry; | 345 | struct GNUNET_PEERSTORE_Record *entry; |
346 | struct GNUNET_HashCode hkey; | ||
345 | size_t size; | 347 | size_t size; |
346 | char *buffer; | 348 | char *buffer; |
347 | char *line; | 349 | char *line; |
@@ -416,8 +418,8 @@ database_setup (struct Plugin *plugin) | |||
416 | sub_system = strtok (line, ","); | 418 | sub_system = strtok (line, ","); |
417 | if (NULL == sub_system) | 419 | if (NULL == sub_system) |
418 | break; | 420 | break; |
419 | peer_id = strtok (NULL, ","); | 421 | peer = strtok (NULL, ","); |
420 | if (NULL == peer_id) | 422 | if (NULL == peer) |
421 | break; | 423 | break; |
422 | key = strtok (NULL, ","); | 424 | key = strtok (NULL, ","); |
423 | if (NULL == key) | 425 | if (NULL == key) |
@@ -431,14 +433,30 @@ database_setup (struct Plugin *plugin) | |||
431 | entry = GNUNET_new (struct GNUNET_PEERSTORE_Record); | 433 | entry = GNUNET_new (struct GNUNET_PEERSTORE_Record); |
432 | entry->sub_system = GNUNET_strdup (sub_system); | 434 | entry->sub_system = GNUNET_strdup (sub_system); |
433 | entry->key = GNUNET_strdup (key); | 435 | entry->key = GNUNET_strdup (key); |
434 | GNUNET_STRINGS_base64_decode (peer_id, | 436 | GNUNET_STRINGS_base64_decode (peer, |
435 | strlen (peer_id), | 437 | strlen (peer), |
436 | (char**)&entry->peer); | 438 | (char**)&entry->peer); |
437 | entry->value_size = GNUNET_STRINGS_base64_decode (value, | 439 | entry->value_size = GNUNET_STRINGS_base64_decode (value, |
438 | strlen (value), | 440 | strlen (value), |
439 | (char**)&entry->value); | 441 | (char**)&entry->value); |
440 | GNUNET_STRINGS_fancy_time_to_absolute (expiry, | 442 | if (GNUNET_SYSERR == GNUNET_STRINGS_fancy_time_to_absolute (expiry, |
441 | entry->expiry); | 443 | entry->expiry)) |
444 | { | ||
445 | GNUNET_free (entry->sub_system); | ||
446 | GNUNET_free (entry->key); | ||
447 | GNUNET_free (entry->peer); | ||
448 | GNUNET_free (entry); | ||
449 | break; | ||
450 | } | ||
451 | peer_id = GNUNET_i2s (entry->peer); | ||
452 | GNUNET_CRYPTO_hash (peer_id, | ||
453 | strlen (peer_id), | ||
454 | &hkey); | ||
455 | |||
456 | GNUNET_assert (GNUNET_OK == GNUNET_CONTAINER_multihashmap_put (plugin->hm, | ||
457 | &hkey, | ||
458 | entry, | ||
459 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE)); | ||
442 | 460 | ||
443 | } | 461 | } |
444 | } | 462 | } |