diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/reclaim/gnunet-service-reclaim.c | 7 | ||||
-rw-r--r-- | src/reclaim/json_reclaim.c | 17 | ||||
-rw-r--r-- | src/reclaim/plugin_rest_reclaim.c | 5 |
3 files changed, 16 insertions, 13 deletions
diff --git a/src/reclaim/gnunet-service-reclaim.c b/src/reclaim/gnunet-service-reclaim.c index a49962b4d..0f0de86d3 100644 --- a/src/reclaim/gnunet-service-reclaim.c +++ b/src/reclaim/gnunet-service-reclaim.c | |||
@@ -778,9 +778,10 @@ attr_store_task (void *cls) | |||
778 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Storing attribute\n"); | 778 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Storing attribute\n"); |
779 | buf_size = GNUNET_RECLAIM_ATTRIBUTE_serialize_get_size (ash->claim); | 779 | buf_size = GNUNET_RECLAIM_ATTRIBUTE_serialize_get_size (ash->claim); |
780 | buf = GNUNET_malloc (buf_size); | 780 | buf = GNUNET_malloc (buf_size); |
781 | // Give the ash a new id | 781 | // Give the ash a new id if unset |
782 | ash->claim->id = | 782 | if (0 == ash->claim->id) |
783 | GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_STRONG, UINT64_MAX); | 783 | ash->claim->id = |
784 | GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_STRONG, UINT64_MAX); | ||
784 | GNUNET_RECLAIM_ATTRIBUTE_serialize (ash->claim, buf); | 785 | GNUNET_RECLAIM_ATTRIBUTE_serialize (ash->claim, buf); |
785 | label = | 786 | label = |
786 | GNUNET_STRINGS_data_to_string_alloc (&ash->claim->id, sizeof (uint64_t)); | 787 | GNUNET_STRINGS_data_to_string_alloc (&ash->claim->id, sizeof (uint64_t)); |
diff --git a/src/reclaim/json_reclaim.c b/src/reclaim/json_reclaim.c index 79110490a..9c186b64a 100644 --- a/src/reclaim/json_reclaim.c +++ b/src/reclaim/json_reclaim.c | |||
@@ -44,10 +44,10 @@ static int | |||
44 | parse_attr (void *cls, json_t *root, struct GNUNET_JSON_Specification *spec) | 44 | parse_attr (void *cls, json_t *root, struct GNUNET_JSON_Specification *spec) |
45 | { | 45 | { |
46 | struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr; | 46 | struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr; |
47 | const char *name_str; | 47 | const char *name_str = NULL; |
48 | const char *val_str; | 48 | const char *val_str = NULL; |
49 | const char *type_str; | 49 | const char *type_str = NULL; |
50 | const char *id_str; | 50 | const char *id_str = NULL; |
51 | char *data; | 51 | char *data; |
52 | int unpack_state; | 52 | int unpack_state; |
53 | uint32_t type; | 53 | uint32_t type; |
@@ -62,10 +62,11 @@ parse_attr (void *cls, json_t *root, struct GNUNET_JSON_Specification *spec) | |||
62 | } | 62 | } |
63 | // interpret single attribute | 63 | // interpret single attribute |
64 | unpack_state = | 64 | unpack_state = |
65 | json_unpack (root, "{s:s, s:s, s:s, s:s!}", "name", &name_str, "id", | 65 | json_unpack (root, "{s:s, s?s, s:s, s:s!}", "name", &name_str, "id", |
66 | &id_str, "type", &type_str, "value", &val_str); | 66 | &id_str, "type", &type_str, "value", &val_str); |
67 | if (0 != unpack_state) { | 67 | if ((0 != unpack_state) || (NULL == name_str) || (NULL == val_str) || |
68 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 68 | (NULL == type_str)) { |
69 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
69 | "Error json object has a wrong format!\n"); | 70 | "Error json object has a wrong format!\n"); |
70 | return GNUNET_SYSERR; | 71 | return GNUNET_SYSERR; |
71 | } | 72 | } |
@@ -76,7 +77,7 @@ parse_attr (void *cls, json_t *root, struct GNUNET_JSON_Specification *spec) | |||
76 | return GNUNET_SYSERR; | 77 | return GNUNET_SYSERR; |
77 | } | 78 | } |
78 | attr = GNUNET_RECLAIM_ATTRIBUTE_claim_new (name_str, type, data, data_size); | 79 | attr = GNUNET_RECLAIM_ATTRIBUTE_claim_new (name_str, type, data, data_size); |
79 | if (0 == strlen (id_str)) | 80 | if ((NULL == id_str) || (0 == strlen (id_str))) |
80 | attr->id = 0; | 81 | attr->id = 0; |
81 | else | 82 | else |
82 | GNUNET_STRINGS_string_to_data (id_str, strlen (id_str), &attr->id, | 83 | GNUNET_STRINGS_string_to_data (id_str, strlen (id_str), &attr->id, |
diff --git a/src/reclaim/plugin_rest_reclaim.c b/src/reclaim/plugin_rest_reclaim.c index 74071d97b..1a3784e64 100644 --- a/src/reclaim/plugin_rest_reclaim.c +++ b/src/reclaim/plugin_rest_reclaim.c | |||
@@ -539,8 +539,9 @@ add_attribute_cont (struct GNUNET_REST_RequestHandle *con_handle, | |||
539 | /** | 539 | /** |
540 | * New ID for attribute | 540 | * New ID for attribute |
541 | */ | 541 | */ |
542 | attribute->id = | 542 | if (0 == attribute->id) |
543 | GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_STRONG, UINT64_MAX); | 543 | attribute->id = |
544 | GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_STRONG, UINT64_MAX); | ||
544 | handle->idp = GNUNET_RECLAIM_connect (cfg); | 545 | handle->idp = GNUNET_RECLAIM_connect (cfg); |
545 | exp = GNUNET_TIME_UNIT_HOURS; | 546 | exp = GNUNET_TIME_UNIT_HOURS; |
546 | handle->idp_op = GNUNET_RECLAIM_attribute_store ( | 547 | handle->idp_op = GNUNET_RECLAIM_attribute_store ( |