commit cd841b66b685604a54030ead95b2d679325d5dd8
parent d1bdcb2618b13c3289492347550feb3fcf1f812d
Author: Schanzenbach, Martin <mschanzenbach@posteo.de>
Date: Tue, 3 Mar 2020 13:30:53 +0100
fix attestation flag rest; fix NULL ptr deref
Diffstat:
2 files changed, 11 insertions(+), 1 deletion(-)
diff --git 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
@@ -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;