fix attestation flag rest; fix NULL ptr deref
authorSchanzenbach, Martin <mschanzenbach@posteo.de>
Tue, 3 Mar 2020 12:30:53 +0000 (13:30 +0100)
committerSchanzenbach, Martin <mschanzenbach@posteo.de>
Tue, 3 Mar 2020 12:30:53 +0000 (13:30 +0100)
src/reclaim/plugin_rest_reclaim.c
src/reclaim/reclaim_attribute.c

index f25241906728818afefc96b35451c348b0e01fce..0246e289ada5b2d960db31334b9cabf89abcf810 100644 (file)
@@ -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,
index 12f124c15f424bba90b2397fed5e4eb7ba9c86bc..69c5351d3c77a95602c232955b5734ef9092bde3 100644 (file)
@@ -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;