- fix coverity
authorMartin Schanzenbach <mschanzenbach@posteo.de>
Mon, 29 Aug 2016 08:20:01 +0000 (08:20 +0000)
committerMartin Schanzenbach <mschanzenbach@posteo.de>
Mon, 29 Aug 2016 08:20:01 +0000 (08:20 +0000)
src/identity-provider/gnunet-service-identity-provider.c
src/jsonapi/jsonapi_resource.c
src/namecache/plugin_namecache_flat.c
src/namestore/plugin_namestore_flat.c

index 2c400dc9c510f4b8c02183dfba6072763f0e2bef..a97955aa685abb7e91f79e5b9997bcbe371141e1 100644 (file)
@@ -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);
index 09217279a21af198e47ca3a7d3d1e71ec580ec03..85bca10eeb860ac167a7046f25721ccfab740d33 100644 (file)
@@ -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)
           {
index c348de63baaabb60ec6d65ec41bd56275c547281..66ab776e3fc99f0a06fe544f59c4c02fa0557d75 100644 (file)
@@ -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;
   }
 
index 869aa3d9f9a3cf301e8d1de60fa86a0fbc38616f..4f5034d26c57ee212ca018b2da8c75927adcb973 100644 (file)
@@ -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);