From: Schanzenbach, Martin Date: Tue, 3 Mar 2020 12:30:53 +0000 (+0100) Subject: fix attestation flag rest; fix NULL ptr deref X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=cd841b66b685604a54030ead95b2d679325d5dd8;p=oweals%2Fgnunet.git fix attestation flag rest; fix NULL ptr deref --- diff --git a/src/reclaim/plugin_rest_reclaim.c b/src/reclaim/plugin_rest_reclaim.c index f25241906..0246e289a 100644 --- a/src/reclaim/plugin_rest_reclaim.c +++ b/src/reclaim/plugin_rest_reclaim.c @@ -964,7 +964,10 @@ attr_collect (void *cls, json_object_set_new (attr_obj, "value", json_string (tmp_value)); json_object_set_new (attr_obj, "name", json_string (attr->name)); - json_object_set_new (attr_obj, "flag", json_string ("1")); + if (GNUNET_RECLAIM_id_is_zero (&attr->attestation)) + json_object_set_new (attr_obj, "flag", json_string ("0")); + else + json_object_set_new (attr_obj, "flag", json_string ("1")); type = GNUNET_RECLAIM_attribute_number_to_typename (attr->type); json_object_set_new (attr_obj, "type", json_string (type)); id_str = GNUNET_STRINGS_data_to_string_alloc (&attr->id, diff --git a/src/reclaim/reclaim_attribute.c b/src/reclaim/reclaim_attribute.c index 12f124c15..69c5351d3 100644 --- a/src/reclaim/reclaim_attribute.c +++ b/src/reclaim/reclaim_attribute.c @@ -366,6 +366,13 @@ GNUNET_RECLAIM_attribute_list_deserialize (const char *data, size_t data_size) ale->attribute = GNUNET_RECLAIM_attribute_deserialize (read_ptr, data_size - (read_ptr - data)); + if (NULL == ale->attribute) + { + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, + "Failed to deserialize malformed attribute.\n"); + GNUNET_free (ale); + return al; + } GNUNET_CONTAINER_DLL_insert (al->list_head, al->list_tail, ale); attr_len = GNUNET_RECLAIM_attribute_serialize_get_size (ale->attribute); read_ptr += attr_len;