-fix use after free
authorChristian Grothoff <christian@grothoff.org>
Fri, 26 Aug 2016 12:52:33 +0000 (12:52 +0000)
committerChristian Grothoff <christian@grothoff.org>
Fri, 26 Aug 2016 12:52:33 +0000 (12:52 +0000)
src/identity-provider/gnunet-identity-token.c
src/namecache/plugin_namecache_flat.c

index 1f480aae0f4e2c5336b41e639add0e72806c3626..e33f47b8b0988eeb1e81169eb45cee0c33a5250a 100644 (file)
@@ -105,42 +105,48 @@ run (void *cls,
   token = NULL;
 
   if (print_token)
-    printf ("Token:\nHeader:\t\t%s\nPayload:\t%s\n", header, payload);
+    printf ("Token:\nHeader:\t\t%s\nPayload:\t%s\n",
+            header,
+            payload);
   GNUNET_free (header);
-  GNUNET_free (payload);
 
   payload_json = json_loads (payload, 0, &error);
-  if ((NULL == payload_json) || !json_is_object (payload_json))
+  GNUNET_free (payload);
+
+  if ((NULL == payload_json) || (! json_is_object (payload_json)) )
   {
     GNUNET_free (val);
     return;
   }
   keystring_json =  json_object_get (payload_json, "iss");
-  if (!json_is_string (keystring_json))
+  if (! json_is_string (keystring_json))
   {
     GNUNET_free (val);
     return;
   }
   keystring = json_string_value (keystring_json);
-  if (GNUNET_OK != GNUNET_CRYPTO_ecdsa_public_key_from_string (keystring,
-                                                               strlen (keystring),
-                                                               &key))
+  if (GNUNET_OK !=
+      GNUNET_CRYPTO_ecdsa_public_key_from_string (keystring,
+                                                  strlen (keystring),
+                                                  &key))
   {
     GNUNET_free (val);
     return;
   }
   GNUNET_STRINGS_string_to_data (signature_b32,
-                                strlen (signature_b32),
-                                &sig,
-                                sizeof (struct GNUNET_CRYPTO_EcdsaSignature));
+                                 strlen (signature_b32),
+                                 &sig,
+                                 sizeof (struct GNUNET_CRYPTO_EcdsaSignature));
 
   if (print_token)
-    printf ("Signature:\t%s\n", keystring);
-
-  if (GNUNET_OK != GNUNET_CRYPTO_ecdsa_verify(GNUNET_SIGNATURE_PURPOSE_GNUID_TOKEN,
-                                              purpose,
-                                              &sig,
-                                              &key))
+    printf ("Signature:\t%s\n",
+            keystring);
+
+  if (GNUNET_OK !=
+      GNUNET_CRYPTO_ecdsa_verify(GNUNET_SIGNATURE_PURPOSE_GNUID_TOKEN,
+                                 purpose,
+                                 &sig,
+                                 &key))
     printf("Signature not OK!\n");
   else
     printf("Signature OK!\n");
index 1d5ea2e122b6434b2a6325a827a4895e6f591aff..c348de63baaabb60ec6d65ec41bd56275c547281 100644 (file)
@@ -154,7 +154,8 @@ database_setup (struct Plugin *plugin)
   buffer[size] = '\0';
 
   GNUNET_DISK_file_close (fh);
-  if (0 < size) {
+  if (0 < size)
+  {
     line = strtok (buffer, "\n");
     while (line != NULL) {
       query = strtok (line, ",");