From 9e9c2fdf87ff362cee3851a0a3e584a0c5696df3 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Fri, 26 Aug 2016 12:52:33 +0000 Subject: [PATCH] -fix use after free --- src/identity-provider/gnunet-identity-token.c | 38 +++++++++++-------- src/namecache/plugin_namecache_flat.c | 3 +- 2 files changed, 24 insertions(+), 17 deletions(-) diff --git a/src/identity-provider/gnunet-identity-token.c b/src/identity-provider/gnunet-identity-token.c index 1f480aae0..e33f47b8b 100644 --- a/src/identity-provider/gnunet-identity-token.c +++ b/src/identity-provider/gnunet-identity-token.c @@ -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"); diff --git a/src/namecache/plugin_namecache_flat.c b/src/namecache/plugin_namecache_flat.c index 1d5ea2e12..c348de63b 100644 --- a/src/namecache/plugin_namecache_flat.c +++ b/src/namecache/plugin_namecache_flat.c @@ -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, ","); -- 2.25.1