From cda23f9580da561752aee04753054aa6225af7cf Mon Sep 17 00:00:00 2001 From: Martin Schanzenbach Date: Mon, 29 Aug 2016 08:20:01 +0000 Subject: [PATCH] - fix coverity --- .../gnunet-service-identity-provider.c | 15 +++++++++------ src/jsonapi/jsonapi_resource.c | 2 +- src/namecache/plugin_namecache_flat.c | 1 + src/namestore/plugin_namestore_flat.c | 6 +++++- 4 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/identity-provider/gnunet-service-identity-provider.c b/src/identity-provider/gnunet-service-identity-provider.c index 2c400dc9c..a97955aa6 100644 --- a/src/identity-provider/gnunet-service-identity-provider.c +++ b/src/identity-provider/gnunet-service-identity-provider.c @@ -597,6 +597,7 @@ token_collect (void *cls, const struct GNUNET_GNSRECORD_Data *token_record; const struct GNUNET_GNSRECORD_Data *token_metadata_record; struct GNUNET_CRYPTO_EcdsaPublicKey *aud_key; + struct GNUNET_CRYPTO_EcdhePrivateKey *priv_key; //There should be only a single record for a token under a label if (2 != rd_count) @@ -627,8 +628,9 @@ token_collect (void *cls, } //Get metadata and decrypt token - ecdhe_privkey = *((struct GNUNET_CRYPTO_EcdhePrivateKey *)token_metadata_record->data); - aud_key = (struct GNUNET_CRYPTO_EcdsaPublicKey *)&(&ecdhe_privkey)[1]; + priv_key = (struct GNUNET_CRYPTO_EcdhePrivateKey *)token_metadata_record->data; + ecdhe_privkey = *priv_key; + aud_key = (struct GNUNET_CRYPTO_EcdsaPublicKey *)&priv_key[1]; scopes = GNUNET_strdup ((char*) aud_key+sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey)); token_parse2 (token_record->data, @@ -717,10 +719,11 @@ attribute_collect (void *cls, GNUNET_CONTAINER_DLL_insert (attr->val_head, attr->val_tail, val); - GNUNET_CONTAINER_multihashmap_put (ego_entry->attr_map, - &key, - attr, - GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY); + GNUNET_assert (GNUNET_OK == + GNUNET_CONTAINER_multihashmap_put (ego_entry->attr_map, + &key, + attr, + GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); } GNUNET_NAMESTORE_zone_iterator_next (ns_it); diff --git a/src/jsonapi/jsonapi_resource.c b/src/jsonapi/jsonapi_resource.c index 09217279a..85bca10ee 100644 --- a/src/jsonapi/jsonapi_resource.c +++ b/src/jsonapi/jsonapi_resource.c @@ -52,7 +52,7 @@ GNUNET_JSONAPI_resource_to_json (const struct GNUNET_JSONAPI_Resource *res, default: res_json = json_array (); rel_res = NULL; - for (rel_res = rel_res->relationship->res_list_head; + for (rel_res = res->relationship->res_list_head; rel_res != NULL; rel_res = rel_res->next) { diff --git a/src/namecache/plugin_namecache_flat.c b/src/namecache/plugin_namecache_flat.c index c348de63b..66ab776e3 100644 --- a/src/namecache/plugin_namecache_flat.c +++ b/src/namecache/plugin_namecache_flat.c @@ -129,6 +129,7 @@ database_setup (struct Plugin *plugin) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Unable to get filesize: %s.\n"), afsdir); + GNUNET_DISK_file_close (fh); return GNUNET_SYSERR; } diff --git a/src/namestore/plugin_namestore_flat.c b/src/namestore/plugin_namestore_flat.c index 869aa3d9f..4f5034d26 100644 --- a/src/namestore/plugin_namestore_flat.c +++ b/src/namestore/plugin_namestore_flat.c @@ -192,7 +192,7 @@ database_setup (struct Plugin *plugin) return GNUNET_SYSERR; } - buffer = GNUNET_malloc (size) + 1; + buffer = GNUNET_malloc (size + 1); if (GNUNET_SYSERR == GNUNET_DISK_file_read (fh, buffer, @@ -201,8 +201,11 @@ database_setup (struct Plugin *plugin) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Unable to read file: %s.\n"), afsdir); + GNUNET_free (buffer); + GNUNET_DISK_file_close (fh); return GNUNET_SYSERR; } + buffer[size] = '\0'; GNUNET_DISK_file_close (fh); if (0 < size) @@ -341,6 +344,7 @@ store_and_free_entries (void *cls, line, strlen (line)); + GNUNET_free (line); GNUNET_free (entry->private_key); GNUNET_free (entry->label); GNUNET_free (entry->record_data); -- 2.25.1